Spaces:
Paused
Paused
anilife search: filter results to titles actually containing the query
Browse files
server.js
CHANGED
|
@@ -455,15 +455,20 @@ async function aniSearch(wd) {
|
|
| 455 |
}
|
| 456 |
aniBreakerRecordSuccess();
|
| 457 |
const list = r.json.result?.item_list || [];
|
| 458 |
-
//
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
return { wd, count: items.length, items, source: 'anilife' };
|
| 468 |
}
|
| 469 |
|
|
|
|
| 455 |
}
|
| 456 |
aniBreakerRecordSuccess();
|
| 457 |
const list = r.json.result?.item_list || [];
|
| 458 |
+
// anilife API는 fuzzy/연관 검색이라 무관한 작품도 반환됨.
|
| 459 |
+
// 제목에 검색어가 실제로 포함된 것만 골라낸다 (대소문자/공백 무시).
|
| 460 |
+
const normalize = s => String(s || '').toLowerCase().replace(/\s+/g, '');
|
| 461 |
+
const needle = normalize(wd);
|
| 462 |
+
const items = list
|
| 463 |
+
.filter(it => normalize(it.name).includes(needle))
|
| 464 |
+
.map(it => ({
|
| 465 |
+
id: it.id,
|
| 466 |
+
title: it.name,
|
| 467 |
+
meta: [it.format, it.episode].filter(Boolean).join(' · '),
|
| 468 |
+
poster: it.image || null,
|
| 469 |
+
href: `/content/${it.id}`,
|
| 470 |
+
source: 'anilife',
|
| 471 |
+
}));
|
| 472 |
return { wd, count: items.length, items, source: 'anilife' };
|
| 473 |
}
|
| 474 |
|