2026-04-23 08:37:48 +02:00
|
|
|
import { createWriteStream } from 'node:fs';
|
|
|
|
|
import { rename } from 'node:fs/promises';
|
Phase 1: lock cron, reload chaud, argon2, providers, IMDb lookup, cache LRU, /health, /metrics, rate limit, UI dark, biome
2026-04-24 07:35:10 +02:00
|
|
|
import { join } from 'node:path';
|
|
|
|
|
import { Readable } from 'node:stream';
|
2026-04-23 08:37:48 +02:00
|
|
|
import { pipeline } from 'node:stream/promises';
|
|
|
|
|
import { createGunzip } from 'node:zlib';
|
Phase 1: lock cron, reload chaud, argon2, providers, IMDb lookup, cache LRU, /health, /metrics, rate limit, UI dark, biome
2026-04-24 07:35:10 +02:00
|
|
|
import { IMDB_DATASETS_BASE, IMDB_RATINGS, ROOT } from '../config.js';
|
2026-04-23 08:37:48 +02:00
|
|
|
|
|
|
|
|
const FILE = 'title.ratings.tsv';
|
|
|
|
|
|
|
|
|
|
export async function syncImdbRatings() {
|
|
|
|
|
const url = `${IMDB_DATASETS_BASE}/${FILE}.gz`;
|
|
|
|
|
const tmpPath = join(ROOT, `${FILE}.tmp`);
|
|
|
|
|
|
|
|
|
|
console.log(`Downloading: "${url}"`);
|
|
|
|
|
const res = await fetch(url);
|
|
|
|
|
if (!res.ok || !res.body) {
|
|
|
|
|
throw new Error(`Failed to fetch ${url}: HTTP ${res.status}`);
|
|
|
|
|
}
|
|
|
|
|
|
Phase 1: lock cron, reload chaud, argon2, providers, IMDb lookup, cache LRU, /health, /metrics, rate limit, UI dark, biome
2026-04-24 07:35:10 +02:00
|
|
|
await pipeline(Readable.fromWeb(res.body), createGunzip(), createWriteStream(tmpPath));
|
2026-04-23 08:37:48 +02:00
|
|
|
|
|
|
|
|
await rename(tmpPath, IMDB_RATINGS);
|
|
|
|
|
console.log(`Wrote ${IMDB_RATINGS}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
|
|
|
syncImdbRatings().catch((err) => {
|
|
|
|
|
console.error(err);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|
|
|
|
|
}
|