Show alt titles in search results

This commit is contained in:
Dymas
2026-06-02 13:03:22 +02:00
parent 94740ebb76
commit 18d82a8678
6 changed files with 64 additions and 4 deletions
+18
View File
@@ -721,6 +721,22 @@ def fetch_anidb_cover(title):
return fetch_anidb_cover_by_aid(match["aid"], fallback_title=match["title"])
def extract_anidb_alternative_titles_for_title(title, primary_title=""):
clean_title = str(title or "").strip()
if not clean_title:
return []
try:
match = resolve_anidb_aid(clean_title)
except Exception as exc:
debug_log("anidb.alt_titles.resolve_failed", title=clean_title, error=exc)
return []
try:
return extract_anidb_alternative_titles(match["aid"], primary_title=primary_title or clean_title)
except Exception as exc:
debug_log("anidb.alt_titles.extract_failed", title=clean_title, aid=match.get("aid"), error=exc)
return []
def fetch_anidb_cover_by_aid(aid, fallback_title=""):
page_url = ANIDB_ANIME_PAGE.format(aid=aid)
debug_log("thumbnail.source.route_lookup", source="AniDB", aid=aid, fallback_title=fallback_title, page_url=page_url)
@@ -882,6 +898,7 @@ def search_anime(query, mode):
title = str(show.get("name") or "").replace('\\"', '"').strip()
if not show.get("_id") or not title:
continue
alternative_titles = extract_anidb_alternative_titles_for_title(title, primary_title=title)
index = len(results) + 1
results.append(
{
@@ -891,6 +908,7 @@ def search_anime(query, mode):
"index": index,
"query": query,
"mode": mode,
"alternative_titles": alternative_titles,
}
)
return results