add max-age slider for search

This commit is contained in:
2025-05-25 01:59:39 +02:00
parent 79aa8f619a
commit aafd1731ce
2 changed files with 117 additions and 42 deletions

View File

@ -24,6 +24,10 @@ function getMatchScore(film, query) {
return 10;
}
function stripSeason(title) {
return normalizeTitle(title).replace(/(saison|season)\s*\d+/g, '').trim();
}
function mergeResults(arrays, query = '', limit = 5) {
const merged = [];
arrays.flat().forEach(entry => {
@ -31,7 +35,19 @@ function mergeResults(arrays, query = '', limit = 5) {
let foundIdx = -1;
for (let i = 0; i < merged.length; i++) {
const m = merged[i];
// Match same year AND at least one significant word in common
// Regroup series/seasons from same source if base title matches (strip "season X"/"saison X")
const isSeason = /saison|season/i.test(entry.title) && /saison|season/i.test(m.title);
if (
m.results[0] && m.results[0].source === entry.source &&
isSeason &&
stripSeason(m.title) === stripSeason(entry.title)
) {
foundIdx = i;
break;
}
// Default merge: Match same year AND at least one significant word in common
if (
(m.year ? m.year.toString() : '') === entryYear &&
hasSignificantWordOverlap(entry.title, m.title)
@ -41,7 +57,6 @@ function mergeResults(arrays, query = '', limit = 5) {
}
}
if (foundIdx >= 0) {
console.log(`[MERGE] ${entry.title} (${entryYear}) merged with ${merged[foundIdx].title} (${entryYear})`);
merged[foundIdx].results.push({ source: entry.source, ...entry });
} else {
merged.push({