Link watchlist titles to providers
This commit is contained in:
@@ -37,7 +37,6 @@ from app_support import (
|
||||
MAX_JSON_BODY_BYTES,
|
||||
METADATA_API,
|
||||
METADATA_REFERER,
|
||||
METADATA_SITE_BASE,
|
||||
MODE_CHOICES,
|
||||
QUALITY_CHOICES,
|
||||
send_discord_webhook_event,
|
||||
@@ -161,11 +160,28 @@ def search_thumbnail_cache_key(title):
|
||||
return f"search-{digest}"
|
||||
|
||||
|
||||
def anime_source_url(show_id, title):
|
||||
normalized_show_id = str(show_id or "").strip()
|
||||
if not normalized_show_id:
|
||||
return f"{METADATA_SITE_BASE}/search-anime?tr=sub&cty=ALL&query={quote(str(title or '').strip(), safe='')}"
|
||||
return f"{METADATA_SITE_BASE}/bangumi/{quote(normalized_show_id, safe='')}"
|
||||
PROVIDER_SITE_BASES = {
|
||||
"anikoto": "https://anikototv.to",
|
||||
"anineko": "https://anineko.to",
|
||||
"pahe": "https://animepahe.pw",
|
||||
}
|
||||
|
||||
|
||||
def anime_source_url(show_id, title, provider=None):
|
||||
parsed_provider, provider_id = provider_bridge.parse_provider_id(show_id, provider or "anikoto")
|
||||
normalized_provider = normalize_provider(provider, parsed_provider)
|
||||
base_url = PROVIDER_SITE_BASES[normalized_provider]
|
||||
normalized_provider_id = str(provider_id or "").strip()
|
||||
if normalized_provider_id:
|
||||
if normalized_provider == "pahe":
|
||||
return f"{base_url}/anime/{quote(normalized_provider_id, safe='')}"
|
||||
return f"{base_url}/watch/{quote(normalized_provider_id, safe='')}"
|
||||
query = quote(str(title or "").strip(), safe="")
|
||||
if normalized_provider == "anineko":
|
||||
return f"{base_url}/browser?keyword={query}"
|
||||
if normalized_provider == "pahe":
|
||||
return f"{base_url}/api?m=search&q={query}"
|
||||
return f"{base_url}/search?keyword={query}"
|
||||
|
||||
|
||||
def infer_image_extension(url, content_type):
|
||||
@@ -1705,7 +1721,7 @@ class WatchlistStore:
|
||||
item["finished_badge"] = (
|
||||
"downloaded" if item["category"] == "finished" and item["downloaded"] else "manual" if item["category"] == "finished" else ""
|
||||
)
|
||||
item["source_url"] = anime_source_url(item.get("show_id"), item.get("title"))
|
||||
item["source_url"] = anime_source_url(item.get("show_id"), item.get("title"), item.get("provider"))
|
||||
thumb_path = thumbnail_file_path(item.get("thumbnail_path"))
|
||||
item["thumbnail_ready"] = bool(thumb_path and thumb_path.exists())
|
||||
item["thumbnail_url"] = cover_route(item.get("show_id"))
|
||||
|
||||
Reference in New Issue
Block a user