Portage complet PHP/Bash vers Node.js (Fastify + worker_threads)

This commit is contained in:
unfr
2026-04-23 08:37:48 +02:00
parent 2f7c990376
commit 3563de52e9
28 changed files with 3348 additions and 0 deletions

36
cron/imdbRatings.js Normal file
View File

@@ -0,0 +1,36 @@
import { createWriteStream } from 'node:fs';
import { rename } from 'node:fs/promises';
import { pipeline } from 'node:stream/promises';
import { createGunzip } from 'node:zlib';
import { Readable } from 'node:stream';
import { join } from 'node:path';
import { ROOT, IMDB_DATASETS_BASE, IMDB_RATINGS } from '../config.js';
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}`);
}
await pipeline(
Readable.fromWeb(res.body),
createGunzip(),
createWriteStream(tmpPath),
);
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);
});
}