dongsik22 commited on
Commit
49e246a
·
1 Parent(s): c83a30f

anilife search: filter results to titles actually containing the query

Browse files
Files changed (1) hide show
  1. server.js +14 -9
server.js CHANGED
@@ -455,15 +455,20 @@ async function aniSearch(wd) {
455
  }
456
  aniBreakerRecordSuccess();
457
  const list = r.json.result?.item_list || [];
458
- // 공통 카드 포맷: { id, title, meta, poster, href, source }
459
- const items = list.map(it => ({
460
- id: it.id,
461
- title: it.name,
462
- meta: [it.format, it.episode].filter(Boolean).join(' · '),
463
- poster: it.image || null,
464
- href: `/content/${it.id}`,
465
- source: 'anilife',
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