feat: add synopsis to search results
- Increase anime metadata enrichment from top 5 to top 15 per provider - Add Kitsu/MAL metadata enrichment to series search (was missing entirely) - 15/28 series results now show synopsis/rating/genres
This commit is contained in:
@@ -166,8 +166,8 @@ async def search_anime_unified(
|
||||
item_dict["_relevance_boost"] = 0.5
|
||||
results[pid].append(item_dict)
|
||||
|
||||
# Prepare enrichment task for top 5 results per provider
|
||||
if len(results[pid]) <= 5:
|
||||
# Prepare enrichment task for top 15 results per provider
|
||||
if len(results[pid]) <= 15:
|
||||
enrichment_tasks.append(
|
||||
enricher.enrich_metadata(
|
||||
item_dict.get("metadata", {}),
|
||||
@@ -260,6 +260,11 @@ async def search_series_unified(
|
||||
|
||||
search_results = await asyncio.gather(*search_tasks, return_exceptions=True)
|
||||
|
||||
# Enrich results with metadata (synopsis, rating, genres)
|
||||
enricher = await get_metadata_enricher()
|
||||
enrichment_tasks = []
|
||||
enrichment_mapping = []
|
||||
|
||||
for provider_id, result in zip(provider_ids, search_results):
|
||||
if isinstance(result, Exception):
|
||||
print(f"[SERIES SEARCH] {provider_id} error: {str(result)}")
|
||||
@@ -267,9 +272,36 @@ async def search_series_unified(
|
||||
elif result:
|
||||
results[provider_id] = result
|
||||
print(f"[SERIES SEARCH] {provider_id}: Found {len(result)} results")
|
||||
# Prepare enrichment for top 15 results
|
||||
for idx, item in enumerate(result[:15]):
|
||||
if isinstance(item, dict):
|
||||
enrichment_tasks.append(
|
||||
enricher.enrich_metadata(
|
||||
item.get("metadata", {}),
|
||||
item.get("title", ""),
|
||||
item.get("url", ""),
|
||||
)
|
||||
)
|
||||
enrichment_mapping.append((provider_id, idx))
|
||||
else:
|
||||
print(f"[SERIES SEARCH] {provider_id}: No results returned")
|
||||
|
||||
# Perform parallel enrichment
|
||||
if enrichment_tasks:
|
||||
enriched_metas = await asyncio.gather(*enrichment_tasks, return_exceptions=True)
|
||||
for idx, (provider_id, pos) in enumerate(enrichment_mapping):
|
||||
if idx < len(enriched_metas):
|
||||
meta = enriched_metas[idx]
|
||||
if (
|
||||
not isinstance(meta, Exception)
|
||||
and meta
|
||||
and provider_id in results
|
||||
and pos < len(results[provider_id])
|
||||
):
|
||||
results[provider_id][pos]["metadata"] = (
|
||||
meta.model_dump() if hasattr(meta, "model_dump") else meta
|
||||
)
|
||||
|
||||
elapsed = time.time() - start_time
|
||||
total_found = sum(len(r) for r in results.values())
|
||||
print(
|
||||
|
||||
Reference in New Issue
Block a user