ani-web 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +220 -0
- package/client/dist/assets/AnimeInfo-B88ZA3gl.js +1 -0
- package/client/dist/assets/AnimeInfo-R63luGTP.css +1 -0
- package/client/dist/assets/AnimeInfoPage-xGVarrXG.js +2 -0
- package/client/dist/assets/Button-Fq9KaUOg.css +1 -0
- package/client/dist/assets/Button-lkEUHIDS.js +1 -0
- package/client/dist/assets/ErrorMessage-BVWNgHMx.css +1 -0
- package/client/dist/assets/ErrorMessage-BXKDLzn8.js +1 -0
- package/client/dist/assets/Home-O1FbN8t_.js +1 -0
- package/client/dist/assets/Home-r0eYbWNc.css +1 -0
- package/client/dist/assets/Insights-CF4K-oO5.css +1 -0
- package/client/dist/assets/Insights-opcB-aTo.js +1 -0
- package/client/dist/assets/MAL-BGM33N5c.js +1 -0
- package/client/dist/assets/MAL-DeQNXXPx.css +1 -0
- package/client/dist/assets/Player-BarbgKjI.css +1 -0
- package/client/dist/assets/Player-CSyGax33.js +9 -0
- package/client/dist/assets/PlayerSettings-BaCVQyw6.js +1 -0
- package/client/dist/assets/PlayerSettings-l6aLKrHh.css +1 -0
- package/client/dist/assets/QueueRail-Cxn5U8kE.js +1 -0
- package/client/dist/assets/QueueRail-DOM_pWkE.css +1 -0
- package/client/dist/assets/RemoveConfirmationModal-BBiogSdf.css +1 -0
- package/client/dist/assets/RemoveConfirmationModal-DatCZQKq.js +1 -0
- package/client/dist/assets/Search-BzO-aRP7.css +1 -0
- package/client/dist/assets/Search-DJxo3BYH.js +1 -0
- package/client/dist/assets/SearchableSelect-BkCrf6E8.css +1 -0
- package/client/dist/assets/SearchableSelect-BzYsMz8B.js +1 -0
- package/client/dist/assets/Settings-Bv9fX-x3.css +1 -0
- package/client/dist/assets/Settings-C5adinOe.js +1 -0
- package/client/dist/assets/SynopsisText-C3AK-aRc.js +1 -0
- package/client/dist/assets/SynopsisText-DsI3mW5v.css +1 -0
- package/client/dist/assets/ToggleSwitch-BIlQxIjg.css +1 -0
- package/client/dist/assets/ToggleSwitch-CrXim14A.js +1 -0
- package/client/dist/assets/Watchlist-CXw0vbNx.js +1 -0
- package/client/dist/assets/Watchlist-a2RHQogs.css +1 -0
- package/client/dist/assets/hls.light-DcbkToIY.js +27 -0
- package/client/dist/assets/index-BzX_xmnf.css +1 -0
- package/client/dist/assets/index-Ciivz6fh.js +178 -0
- package/client/dist/assets/useAnimeInfoData-Dqthchpa.js +1 -0
- package/client/dist/assets/useIsMobile-BviODivc.js +1 -0
- package/client/dist/assets/vendor-Bc4EraM_.js +3 -0
- package/client/dist/favicon.ico +0 -0
- package/client/dist/index.html +35 -0
- package/client/dist/logo.png +0 -0
- package/client/dist/placeholder.svg +4 -0
- package/client/dist/robots.txt +3 -0
- package/client/package.json +58 -0
- package/orchestrator.js +323 -0
- package/package.json +88 -0
- package/server/.env +1 -0
- package/server/dist/config.js +89 -0
- package/server/dist/constants.json +1359 -0
- package/server/dist/controllers/auth.controller.js +215 -0
- package/server/dist/controllers/data.controller.js +232 -0
- package/server/dist/controllers/insights.controller.js +200 -0
- package/server/dist/controllers/proxy.controller.js +353 -0
- package/server/dist/controllers/settings.controller.js +159 -0
- package/server/dist/controllers/watchlist.controller.js +749 -0
- package/server/dist/db.js +152 -0
- package/server/dist/discord-rpc.js +279 -0
- package/server/dist/github-sync.js +342 -0
- package/server/dist/google.js +310 -0
- package/server/dist/logger.js +21 -0
- package/server/dist/providers/123anime.provider.js +226 -0
- package/server/dist/providers/allanime.provider.js +736 -0
- package/server/dist/providers/animepahe.provider.js +457 -0
- package/server/dist/providers/animeya.provider.js +787 -0
- package/server/dist/providers/megaplay.provider.js +264 -0
- package/server/dist/providers/provider.interface.js +2 -0
- package/server/dist/rclone.js +126 -0
- package/server/dist/repositories/insights.repository.js +42 -0
- package/server/dist/repositories/notifications.repository.js +30 -0
- package/server/dist/repositories/queue.repository.js +38 -0
- package/server/dist/repositories/settings.repository.js +14 -0
- package/server/dist/repositories/shows-meta.repository.js +41 -0
- package/server/dist/repositories/watched-episodes.repository.js +67 -0
- package/server/dist/repositories/watchlist.repository.js +80 -0
- package/server/dist/routes/auth.routes.js +26 -0
- package/server/dist/routes/data.routes.js +42 -0
- package/server/dist/routes/insights.routes.js +12 -0
- package/server/dist/routes/proxy.routes.js +14 -0
- package/server/dist/routes/settings.routes.js +27 -0
- package/server/dist/routes/watchlist.routes.js +46 -0
- package/server/dist/server.js +229 -0
- package/server/dist/sync-config.js +28 -0
- package/server/dist/sync.js +427 -0
- package/server/dist/utils/db-utils.js +15 -0
- package/server/dist/utils/env.utils.js +79 -0
- package/server/dist/utils/machine-id.js +46 -0
- package/server/dist/utils/request-context.js +5 -0
- package/server/package.json +19 -0
package/orchestrator.js
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('child_process')
|
|
3
|
+
const readline = require('readline')
|
|
4
|
+
const http = require('http')
|
|
5
|
+
const os = require('os')
|
|
6
|
+
const path = require('path')
|
|
7
|
+
const axios = require('axios')
|
|
8
|
+
|
|
9
|
+
const mode = process.argv[2] || 'prod'
|
|
10
|
+
const isWin = os.platform() === 'win32'
|
|
11
|
+
const npmCmd = isWin ? 'npm.cmd' : 'npm'
|
|
12
|
+
|
|
13
|
+
const colors = {
|
|
14
|
+
reset: '\x1b[0m',
|
|
15
|
+
server: '\x1b[36m',
|
|
16
|
+
client: '\x1b[32m',
|
|
17
|
+
system: '\x1b[33m',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (mode === '--version' || mode === '-v') {
|
|
21
|
+
const pkg = require('./package.json')
|
|
22
|
+
console.log(`ani-web version ${pkg.version}`)
|
|
23
|
+
process.exit(0)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function checkForUpdates() {
|
|
27
|
+
if (process.argv.includes('--no-update') || mode === 'dev') return
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const npmGlobalPrefix = require('child_process')
|
|
31
|
+
.execSync('npm config get prefix', { encoding: 'utf8' })
|
|
32
|
+
.trim()
|
|
33
|
+
const scriptPath = path.resolve(__dirname)
|
|
34
|
+
const isGlobalInstall = scriptPath.includes(npmGlobalPrefix)
|
|
35
|
+
|
|
36
|
+
const pkg = require('./package.json')
|
|
37
|
+
const current = pkg.version
|
|
38
|
+
|
|
39
|
+
if (isGlobalInstall) {
|
|
40
|
+
const { data } = await axios.get('https://registry.npmjs.org/ani-web/latest', {
|
|
41
|
+
timeout: 3000,
|
|
42
|
+
headers: { 'User-Agent': 'ani-web-cli' },
|
|
43
|
+
})
|
|
44
|
+
const latest = data.version
|
|
45
|
+
|
|
46
|
+
if (current !== latest) {
|
|
47
|
+
console.log(
|
|
48
|
+
`\n${colors.system}[Update]${colors.reset} ` +
|
|
49
|
+
`New version ${colors.client}${latest}${colors.reset} available (current: ${current})`
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
if (process.stdin.isTTY) {
|
|
53
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
54
|
+
const answer = await new Promise((resolve) => {
|
|
55
|
+
rl.question(
|
|
56
|
+
`${colors.system}[Update]${colors.reset} Would you like to perform a clean install now? (y/N) `,
|
|
57
|
+
(ans) => {
|
|
58
|
+
rl.close()
|
|
59
|
+
resolve(ans.toLowerCase())
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
if (answer === 'y' || answer === 'yes') {
|
|
65
|
+
console.log(`${colors.system}[Update]${colors.reset} Updating ani-web...`)
|
|
66
|
+
try {
|
|
67
|
+
require('child_process').execSync(`${npmCmd} install -g ani-web@latest`, {
|
|
68
|
+
stdio: 'inherit',
|
|
69
|
+
})
|
|
70
|
+
console.log(
|
|
71
|
+
`\n${colors.system}[Update]${colors.reset} Update successful! Please restart ani-web to apply changes.`
|
|
72
|
+
)
|
|
73
|
+
process.exit(0)
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error(
|
|
76
|
+
`\n${colors.system}[Update]${colors.reset} Update failed: ${err.message}`
|
|
77
|
+
)
|
|
78
|
+
if (!isWin) {
|
|
79
|
+
console.log(
|
|
80
|
+
`${colors.system}[Update]${colors.reset} Hint: You might need to run with sudo:`
|
|
81
|
+
)
|
|
82
|
+
console.log(
|
|
83
|
+
`${colors.system}[Update]${colors.reset} ${colors.client}sudo ani-web${colors.reset}\n`
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
console.log(
|
|
87
|
+
`${colors.system}[Update]${colors.reset} Continuing with current version...\n`
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
console.log(
|
|
92
|
+
`${colors.system}[Update]${colors.reset} Continuing with version ${current}...\n`
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
if (process.stdin.isTTY) process.stdin.resume()
|
|
96
|
+
} else {
|
|
97
|
+
console.log(
|
|
98
|
+
`${colors.system}[Update]${colors.reset} Run: npm install -g ani-web to update.\n`
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
const { data } = await axios.get(
|
|
104
|
+
'https://api.github.com/repos/serifpersia/ani-web/releases/latest',
|
|
105
|
+
{ timeout: 3000 }
|
|
106
|
+
)
|
|
107
|
+
const latestDate = new Date(data.published_at)
|
|
108
|
+
const pkgDate = new Date(pkg.versionDate || 0)
|
|
109
|
+
|
|
110
|
+
if (latestDate > pkgDate) {
|
|
111
|
+
console.log(`\n${colors.system}====================================================`)
|
|
112
|
+
console.log(`${colors.system}[Update Available]${colors.reset} New version found!`)
|
|
113
|
+
console.log(
|
|
114
|
+
`Please download the latest release: ${colors.client}${data.html_url}${colors.reset}`
|
|
115
|
+
)
|
|
116
|
+
console.log(`Replace your current files with the new ones from the zip.`)
|
|
117
|
+
console.log(
|
|
118
|
+
`${colors.system}====================================================\n${colors.reset}`
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
// Silently ignore network/registry errors
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const SERVER_DIR = path.join(__dirname, 'server')
|
|
128
|
+
const CLIENT_DIR = path.join(__dirname, 'client')
|
|
129
|
+
|
|
130
|
+
let syncSpinner = null
|
|
131
|
+
let syncMessage = ''
|
|
132
|
+
let syncDots = 0
|
|
133
|
+
|
|
134
|
+
const startSpinner = (msg) => {
|
|
135
|
+
syncMessage = msg
|
|
136
|
+
syncDots = 0
|
|
137
|
+
process.stdout.write(`${colors.system}[System]${colors.reset} ${msg}`)
|
|
138
|
+
syncSpinner = setInterval(() => {
|
|
139
|
+
syncDots = (syncDots + 1) % 4
|
|
140
|
+
process.stdout.write(
|
|
141
|
+
`\r${colors.system}[System]${colors.reset} ${msg}${'.'.repeat(syncDots)}${' '.repeat(3 - syncDots)}`
|
|
142
|
+
)
|
|
143
|
+
}, 400)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const stopSpinner = () => {
|
|
147
|
+
if (syncSpinner) {
|
|
148
|
+
clearInterval(syncSpinner)
|
|
149
|
+
syncSpinner = null
|
|
150
|
+
process.stdout.write('\n')
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const log = (prefix, color, data) => {
|
|
155
|
+
const str = data.toString()
|
|
156
|
+
|
|
157
|
+
if (str.includes('[SYNC_START]')) {
|
|
158
|
+
const parts = str.split('[SYNC_START]')
|
|
159
|
+
if (parts[1]) startSpinner(parts[1].split('\n')[0].trim())
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
if (str.includes('[SYNC_END]')) {
|
|
163
|
+
stopSpinner()
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (str.includes('[SERVER_EXIT]')) {
|
|
168
|
+
stopSpinner()
|
|
169
|
+
console.log(
|
|
170
|
+
`${colors.system}[System]${colors.reset} Server sync complete. Shutting down cleanly.`
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
if (isWin) {
|
|
174
|
+
if (serverProcess) spawn('taskkill', ['/pid', serverProcess.pid, '/f', '/t'], { shell: true })
|
|
175
|
+
if (clientProcess) spawn('taskkill', ['/pid', clientProcess.pid, '/f', '/t'], { shell: true })
|
|
176
|
+
} else {
|
|
177
|
+
if (serverProcess) {
|
|
178
|
+
serverProcess.kill('SIGTERM')
|
|
179
|
+
setTimeout(() => {
|
|
180
|
+
if (serverProcess.connected || !serverProcess.killed) serverProcess.kill('SIGKILL')
|
|
181
|
+
}, 5000)
|
|
182
|
+
}
|
|
183
|
+
if (clientProcess) {
|
|
184
|
+
clientProcess.kill('SIGTERM')
|
|
185
|
+
setTimeout(() => {
|
|
186
|
+
if (clientProcess.connected || !clientProcess.killed) clientProcess.kill('SIGKILL')
|
|
187
|
+
}, 5000)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
setTimeout(() => process.exit(0), 5500)
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const lines = str.split('\n').filter((line) => line.trim() !== '')
|
|
195
|
+
if (lines.length === 0) return
|
|
196
|
+
|
|
197
|
+
if (syncSpinner) {
|
|
198
|
+
process.stdout.write('\r\x1b[K')
|
|
199
|
+
for (const line of lines) {
|
|
200
|
+
console.log(`${color}[${prefix}]${colors.reset} ${line}`)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
process.stdout.write(
|
|
204
|
+
`${colors.system}[System]${colors.reset} ${syncMessage}${'.'.repeat(syncDots)}${' '.repeat(3 - syncDots)}`
|
|
205
|
+
)
|
|
206
|
+
} else {
|
|
207
|
+
for (const line of lines) {
|
|
208
|
+
console.log(`${color}[${prefix}]${colors.reset} ${line}`)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const spawnOpts = (cwd) => ({ stdio: 'pipe', shell: isWin, cwd })
|
|
214
|
+
let serverProcess, clientProcess
|
|
215
|
+
let isShuttingDown = false
|
|
216
|
+
|
|
217
|
+
async function main() {
|
|
218
|
+
console.log(
|
|
219
|
+
`${colors.system}[System]${colors.reset} Starting ani-web in ${mode.toUpperCase()} mode...`
|
|
220
|
+
)
|
|
221
|
+
console.log(
|
|
222
|
+
`${colors.system}[System]${colors.reset} Press 'q' or 'Ctrl+C' to cleanly exit and sync data.\n`
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
if (mode === 'dev') {
|
|
226
|
+
serverProcess = spawn(npmCmd, ['run', 'dev'], spawnOpts(SERVER_DIR))
|
|
227
|
+
clientProcess = spawn(npmCmd, ['run', 'dev'], spawnOpts(CLIENT_DIR))
|
|
228
|
+
} else {
|
|
229
|
+
const serverPath = path.join(SERVER_DIR, 'dist', 'server.js')
|
|
230
|
+
serverProcess = spawn('node', ['--max-old-space-size=256', serverPath], spawnOpts(SERVER_DIR))
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (serverProcess) {
|
|
234
|
+
serverProcess.stdout.on('data', (data) => log('Server', colors.server, data))
|
|
235
|
+
serverProcess.stderr.on('data', (data) => log('Server', colors.server, data))
|
|
236
|
+
serverProcess.on('exit', (code) => {
|
|
237
|
+
if (!isShuttingDown) {
|
|
238
|
+
log('System', colors.system, `Server crashed or exited prematurely.`)
|
|
239
|
+
process.exit(code || 0)
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (clientProcess) {
|
|
245
|
+
clientProcess.stdout.on('data', (data) => log('Client', colors.client, data))
|
|
246
|
+
clientProcess.stderr.on('data', (data) => log('Client', colors.client, data))
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (process.stdin.isTTY) {
|
|
250
|
+
process.stdin.resume()
|
|
251
|
+
readline.emitKeypressEvents(process.stdin)
|
|
252
|
+
process.stdin.setRawMode(true)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
process.stdin.on('keypress', (str, key) => {
|
|
256
|
+
if (key && (key.name === 'q' || (key.ctrl && key.name === 'c'))) {
|
|
257
|
+
shutdown()
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const shutdown = () => {
|
|
263
|
+
if (isShuttingDown) return
|
|
264
|
+
isShuttingDown = true
|
|
265
|
+
console.log(`\n${colors.system}[System]${colors.reset} Initiating clean shutdown...`)
|
|
266
|
+
|
|
267
|
+
if (clientProcess) {
|
|
268
|
+
if (isWin) spawn('taskkill', ['/pid', clientProcess.pid, '/f', '/t'], { shell: true })
|
|
269
|
+
else {
|
|
270
|
+
clientProcess.kill('SIGTERM')
|
|
271
|
+
setTimeout(() => {
|
|
272
|
+
if (clientProcess.connected || !clientProcess.killed) clientProcess.kill('SIGKILL')
|
|
273
|
+
}, 5000)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const req = http.request({
|
|
278
|
+
hostname: '127.0.0.1',
|
|
279
|
+
port: 3000,
|
|
280
|
+
path: '/api/internal/shutdown',
|
|
281
|
+
method: 'POST',
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
req.on('error', () => {
|
|
285
|
+
console.log(`${colors.system}[System]${colors.reset} Server unreachable, forcing exit.`)
|
|
286
|
+
if (isWin && serverProcess)
|
|
287
|
+
spawn('taskkill', ['/pid', serverProcess.pid, '/f', '/t'], { shell: true })
|
|
288
|
+
else if (serverProcess) {
|
|
289
|
+
serverProcess.kill('SIGTERM')
|
|
290
|
+
setTimeout(() => {
|
|
291
|
+
if (serverProcess.connected || !serverProcess.killed) serverProcess.kill('SIGKILL')
|
|
292
|
+
process.exit(0)
|
|
293
|
+
}, 5000)
|
|
294
|
+
return
|
|
295
|
+
}
|
|
296
|
+
process.exit(0)
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
req.end()
|
|
300
|
+
|
|
301
|
+
setTimeout(() => {
|
|
302
|
+
console.log(`${colors.system}[System]${colors.reset} Force exiting after timeout.`)
|
|
303
|
+
if (isWin && serverProcess)
|
|
304
|
+
spawn('taskkill', ['/pid', serverProcess.pid, '/f', '/t'], { shell: true })
|
|
305
|
+
else if (serverProcess) {
|
|
306
|
+
serverProcess.kill('SIGTERM')
|
|
307
|
+
setTimeout(() => {
|
|
308
|
+
if (serverProcess.connected || !serverProcess.killed) serverProcess.kill('SIGKILL')
|
|
309
|
+
process.exit(1)
|
|
310
|
+
}, 5000)
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
process.exit(1)
|
|
314
|
+
}, 15000)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
process.on('SIGINT', () => {
|
|
318
|
+
shutdown()
|
|
319
|
+
})
|
|
320
|
+
;(async () => {
|
|
321
|
+
await checkForUpdates()
|
|
322
|
+
main()
|
|
323
|
+
})()
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ani-web",
|
|
3
|
+
"version": "2.0.7",
|
|
4
|
+
"description": "A web application for watching anime.",
|
|
5
|
+
"main": "orchestrator.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ani-web": "orchestrator.js"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=22.5.0"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"install:client": "npm install --prefix client",
|
|
14
|
+
"build": "npm run build --prefix client && npm run build --prefix server",
|
|
15
|
+
"start": "node orchestrator.js prod",
|
|
16
|
+
"dev": "node orchestrator.js dev",
|
|
17
|
+
"client": "npm start --prefix client",
|
|
18
|
+
"server": "npm run start --prefix server",
|
|
19
|
+
"preview": "node orchestrator.js prod",
|
|
20
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
21
|
+
"lint": "npm run lint --prefix client && npm run lint --prefix server",
|
|
22
|
+
"format": "prettier --write .",
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"update-version": "node update-version.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"orchestrator.js",
|
|
28
|
+
"client/dist",
|
|
29
|
+
"server/dist",
|
|
30
|
+
"server/.env",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"README.md",
|
|
33
|
+
"package.json"
|
|
34
|
+
],
|
|
35
|
+
"keywords": [
|
|
36
|
+
"anime",
|
|
37
|
+
"react",
|
|
38
|
+
"express",
|
|
39
|
+
"typescript",
|
|
40
|
+
"streaming",
|
|
41
|
+
"cli"
|
|
42
|
+
],
|
|
43
|
+
"author": "",
|
|
44
|
+
"license": "ISC",
|
|
45
|
+
"type": "commonjs",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@octokit/auth-oauth-device": "^8.0.3",
|
|
48
|
+
"@octokit/rest": "^22.0.1",
|
|
49
|
+
"@xhayper/discord-rpc": "^1.3.4",
|
|
50
|
+
"axios": "^1.15.1",
|
|
51
|
+
"axios-retry": "^4.5.0",
|
|
52
|
+
"cheerio": "^1.2.0",
|
|
53
|
+
"chokidar": "^5.0.0",
|
|
54
|
+
"compression": "^1.8.1",
|
|
55
|
+
"cors": "^2.8.5",
|
|
56
|
+
"crypto-js": "^4.2.0",
|
|
57
|
+
"dotenv": "^17.4.2",
|
|
58
|
+
"express": "^5.1.0",
|
|
59
|
+
"multer": "^2.0.2",
|
|
60
|
+
"node-cache": "^5.1.2",
|
|
61
|
+
"pino": "^10.3.1",
|
|
62
|
+
"pino-pretty": "^13.1.1",
|
|
63
|
+
"xml2js": "^0.6.2"
|
|
64
|
+
},
|
|
65
|
+
"overrides": {
|
|
66
|
+
"encoding-sniffer": "^1.0.2",
|
|
67
|
+
"esbuild": "^0.28.1",
|
|
68
|
+
"undici": "^8.5.0"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@eslint/js": "^10.0.1",
|
|
72
|
+
"@types/compression": "^1.8.1",
|
|
73
|
+
"@types/cors": "^2.8.19",
|
|
74
|
+
"@types/crypto-js": "^4.2.2",
|
|
75
|
+
"@types/express": "^5.0.0",
|
|
76
|
+
"@types/multer": "^2.1.0",
|
|
77
|
+
"@types/node": "^22.5.0",
|
|
78
|
+
"@types/xml2js": "^0.4.14",
|
|
79
|
+
"eslint": "^10.2.1",
|
|
80
|
+
"globals": "^17.5.0",
|
|
81
|
+
"nodemon": "^3.1.14",
|
|
82
|
+
"prettier": "^3.8.3",
|
|
83
|
+
"ts-node": "^10.9.2",
|
|
84
|
+
"typescript": "^6.0.3",
|
|
85
|
+
"typescript-eslint": "^8.18.1"
|
|
86
|
+
},
|
|
87
|
+
"versionDate": "2026-06-28T21:27:29.300Z"
|
|
88
|
+
}
|
package/server/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DISCORD_CLIENT_ID=1512253778022367426
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CONFIG = exports.SERVER_ROOT = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
11
|
+
exports.SERVER_ROOT = path_1.default.resolve(__dirname, '..');
|
|
12
|
+
const PACKAGE_ROOT = path_1.default.resolve(exports.SERVER_ROOT, '..');
|
|
13
|
+
function resolveDataRoot() {
|
|
14
|
+
if (process.platform === 'win32' && process.env.APPDATA) {
|
|
15
|
+
return path_1.default.join(process.env.APPDATA, 'ani-web');
|
|
16
|
+
}
|
|
17
|
+
if (process.platform === 'darwin') {
|
|
18
|
+
return path_1.default.join(os_1.default.homedir(), 'Library', 'Application Support', 'ani-web');
|
|
19
|
+
}
|
|
20
|
+
if (process.env.XDG_DATA_HOME) {
|
|
21
|
+
return path_1.default.join(process.env.XDG_DATA_HOME, 'ani-web');
|
|
22
|
+
}
|
|
23
|
+
return path_1.default.join(os_1.default.homedir(), '.local', 'share', 'ani-web');
|
|
24
|
+
}
|
|
25
|
+
function moveFileIfNeeded(sourcePath, destinationPath) {
|
|
26
|
+
if (!fs_1.default.existsSync(sourcePath) || fs_1.default.existsSync(destinationPath)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
fs_1.default.renameSync(sourcePath, destinationPath);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
fs_1.default.copyFileSync(sourcePath, destinationPath);
|
|
34
|
+
fs_1.default.unlinkSync(sourcePath);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function migrateLegacyData(packageServerRoot, dataRoot) {
|
|
38
|
+
const legacyFiles = [
|
|
39
|
+
'.env',
|
|
40
|
+
'google_tokens.json',
|
|
41
|
+
'sync_manifest.json',
|
|
42
|
+
'sync_manifest.dev.json',
|
|
43
|
+
'anime.db',
|
|
44
|
+
'anime.db-shm',
|
|
45
|
+
'anime.db-wal',
|
|
46
|
+
'anime.dev.db',
|
|
47
|
+
'anime.dev.db-shm',
|
|
48
|
+
'anime.dev.db-wal',
|
|
49
|
+
];
|
|
50
|
+
fs_1.default.mkdirSync(dataRoot, { recursive: true });
|
|
51
|
+
for (const filename of legacyFiles) {
|
|
52
|
+
moveFileIfNeeded(path_1.default.join(packageServerRoot, filename), path_1.default.join(dataRoot, filename));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const DATA_ROOT = resolveDataRoot();
|
|
56
|
+
const ENV_PATH = path_1.default.join(DATA_ROOT, '.env');
|
|
57
|
+
migrateLegacyData(exports.SERVER_ROOT, DATA_ROOT);
|
|
58
|
+
dotenv_1.default.config({ path: path_1.default.join(exports.SERVER_ROOT, '.env') });
|
|
59
|
+
dotenv_1.default.config({ path: ENV_PATH, override: true });
|
|
60
|
+
const IS_DEV = process.argv.includes('--dev');
|
|
61
|
+
const PORT = 3000;
|
|
62
|
+
const GOOGLE_REDIRECT_URI = IS_DEV
|
|
63
|
+
? 'http://localhost:5173/api/auth/google/callback'
|
|
64
|
+
: `http://localhost:${PORT}/api/auth/google/callback`;
|
|
65
|
+
exports.CONFIG = {
|
|
66
|
+
ROOT: DATA_ROOT,
|
|
67
|
+
SERVER_ROOT: exports.SERVER_ROOT,
|
|
68
|
+
PACKAGE_ROOT,
|
|
69
|
+
ENV_PATH,
|
|
70
|
+
TOKEN_PATH: path_1.default.join(DATA_ROOT, 'google_tokens.json'),
|
|
71
|
+
LOCAL_MANIFEST_PATH: path_1.default.join(DATA_ROOT, IS_DEV ? 'sync_manifest.dev.json' : 'sync_manifest.json'),
|
|
72
|
+
DB_NAME_PROD: 'anime.db',
|
|
73
|
+
DB_NAME_DEV: 'anime.dev.db',
|
|
74
|
+
REMOTE_FOLDER_PROD: 'aniweb_db',
|
|
75
|
+
REMOTE_FOLDER_DEV: 'aniweb_dev_db',
|
|
76
|
+
MANIFEST_FILENAME: IS_DEV ? 'sync_manifest.dev.json' : 'sync_manifest.json',
|
|
77
|
+
GOOGLE_SCOPES: [
|
|
78
|
+
'https://www.googleapis.com/auth/drive',
|
|
79
|
+
'https://www.googleapis.com/auth/userinfo.profile',
|
|
80
|
+
],
|
|
81
|
+
IS_DEV,
|
|
82
|
+
PORT,
|
|
83
|
+
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
|
|
84
|
+
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
|
|
85
|
+
GOOGLE_REDIRECT_URI: GOOGLE_REDIRECT_URI,
|
|
86
|
+
RCLONE_REMOTE: process.env.RCLONE_REMOTE,
|
|
87
|
+
SYNC_PROVIDER: process.env.SYNC_PROVIDER,
|
|
88
|
+
DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
|
|
89
|
+
};
|