Phase 1: lock cron, reload chaud, argon2, providers, IMDb lookup, cache LRU, /health, /metrics, rate limit, UI dark, biome
This commit is contained in:
@@ -2,13 +2,17 @@
|
||||
|
||||
import { createReadStream, existsSync, readdirSync, unlinkSync } from 'node:fs';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { createInterface } from 'node:readline';
|
||||
import { join } from 'node:path';
|
||||
import { createInterface } from 'node:readline';
|
||||
import {
|
||||
TMDBINTEGRAL_DIR, JUSTWATCH_MOVIE_DIR, JUSTWATCH_TV_DIR, TMDB_API_KEY, TMDB_API_BASE,
|
||||
JUSTWATCH_MOVIE_DIR,
|
||||
JUSTWATCH_TV_DIR,
|
||||
TMDB_API_BASE,
|
||||
TMDB_API_KEY,
|
||||
TMDBINTEGRAL_DIR,
|
||||
} from '../config.js';
|
||||
import { Limiter } from '../lib/http.js';
|
||||
import { justwatchDir, justwatchPath, bucket } from '../lib/paths.js';
|
||||
import { bucket, justwatchDir, justwatchPath } from '../lib/paths.js';
|
||||
|
||||
const DOWNLOAD_CONCURRENCY = 16;
|
||||
|
||||
@@ -22,7 +26,9 @@ async function readMasterIds(type) {
|
||||
try {
|
||||
const obj = JSON.parse(line);
|
||||
if (typeof obj.id === 'number') ids.push(obj.id);
|
||||
} catch { /* ignore */ }
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
@@ -50,10 +56,18 @@ function removeOrphans(type, ids) {
|
||||
const baseDir = type === 'movie' ? JUSTWATCH_MOVIE_DIR : JUSTWATCH_TV_DIR;
|
||||
const expected = new Set(ids);
|
||||
let buckets;
|
||||
try { buckets = readdirSync(baseDir); } catch { return; }
|
||||
try {
|
||||
buckets = readdirSync(baseDir);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
for (const b of buckets) {
|
||||
let entries;
|
||||
try { entries = readdirSync(join(baseDir, b)); } catch { continue; }
|
||||
try {
|
||||
entries = readdirSync(join(baseDir, b));
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
for (const fname of entries) {
|
||||
if (!fname.endsWith('.json')) continue;
|
||||
const id = parseInt(fname.slice(0, -5), 10);
|
||||
@@ -61,7 +75,11 @@ function removeOrphans(type, ids) {
|
||||
if (!expected.has(id)) {
|
||||
const p = join(baseDir, b, fname);
|
||||
console.log(`Removing: "justwatch${type}/${b}/${fname}"`);
|
||||
try { unlinkSync(p); } catch { /* ignore */ }
|
||||
try {
|
||||
unlinkSync(p);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user