Phase 1: lock cron, reload chaud, argon2, providers, IMDb lookup, cache LRU, /health, /metrics, rate limit, UI dark, biome
This commit is contained in:
@@ -9,21 +9,23 @@
|
||||
|
||||
import { createReadStream, existsSync, readFileSync } from 'node:fs';
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
import { createInterface } from 'node:readline';
|
||||
import { join } from 'node:path';
|
||||
import { TMDBINTEGRAL_DIR, NB_SEARCH_PARTS } from '../config.js';
|
||||
import { createInterface } from 'node:readline';
|
||||
import { NB_SEARCH_PARTS, TMDBINTEGRAL_DIR } from '../config.js';
|
||||
import { mbStrlen } from '../lib/mbLevenshtein.js';
|
||||
import { entryPath } from '../lib/paths.js';
|
||||
import { filterTitle } from '../lib/titleFilter.js';
|
||||
import { mbStrlen } from '../lib/mbLevenshtein.js';
|
||||
|
||||
function lower(s) { return s.toLocaleLowerCase(); }
|
||||
function lower(s) {
|
||||
return s.toLocaleLowerCase();
|
||||
}
|
||||
|
||||
function extractEnglishTitle(detail, type) {
|
||||
const tr = detail?.translations?.translations;
|
||||
if (!Array.isArray(tr)) return '';
|
||||
for (const t of tr) {
|
||||
if (t.iso_639_1 === 'en') {
|
||||
return type === 'movie' ? (t.data?.title || '') : (t.data?.name || '');
|
||||
return type === 'movie' ? t.data?.title || '' : t.data?.name || '';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
@@ -73,20 +75,13 @@ function buildEntry(masterObj, detail, type) {
|
||||
const seen = new Set();
|
||||
const uniqYears = [];
|
||||
for (const y of years) {
|
||||
if (!seen.has(y)) { seen.add(y); uniqYears.push(y); }
|
||||
if (!seen.has(y)) {
|
||||
seen.add(y);
|
||||
uniqYears.push(y);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
tmdb,
|
||||
title,
|
||||
englishTitle,
|
||||
originalTitle,
|
||||
lower(ft),
|
||||
lower(fe),
|
||||
lower(fo),
|
||||
uniqYears,
|
||||
popularity,
|
||||
];
|
||||
return [tmdb, title, englishTitle, originalTitle, lower(ft), lower(fe), lower(fo), uniqYears, popularity];
|
||||
}
|
||||
|
||||
export async function buildSearch(type, nbParts = NB_SEARCH_PARTS) {
|
||||
@@ -99,11 +94,19 @@ export async function buildSearch(type, nbParts = NB_SEARCH_PARTS) {
|
||||
for await (const line of rl) {
|
||||
if (!line) continue;
|
||||
let masterObj;
|
||||
try { masterObj = JSON.parse(line); } catch { continue; }
|
||||
try {
|
||||
masterObj = JSON.parse(line);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
const path = entryPath(type, masterObj.id);
|
||||
if (!existsSync(path)) continue;
|
||||
let detail;
|
||||
try { detail = JSON.parse(readFileSync(path, 'utf8')); } catch { continue; }
|
||||
try {
|
||||
detail = JSON.parse(readFileSync(path, 'utf8'));
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
const entry = buildEntry(masterObj, detail, type);
|
||||
if (entry) database.push(entry);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user