Improve media detail UX and preserve search context.
Render structured media details instead of raw JSON, keep search state when navigating back from detail, and surface HDHive link validation and fallback resource-page links for clearer troubleshooting. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,6 +40,15 @@ def normalize_resource(search_data, unlock_data):
|
||||
resolution = (search_data or {}).get("video_resolution")
|
||||
source = (search_data or {}).get("source")
|
||||
subtitle_language = (search_data or {}).get("subtitle_language")
|
||||
unlock_url = (unlock_data or {}).get("full_url") or (unlock_data or {}).get("url") or ""
|
||||
media_url = (search_data or {}).get("media_url") or ""
|
||||
detail_url = media_url
|
||||
if not detail_url and (search_data or {}).get("media_slug"):
|
||||
detail_url = f"{Config.HDHIVE_BASE_URL}/movie/{(search_data or {}).get('media_slug')}"
|
||||
|
||||
validate_status = (search_data or {}).get("validate_status")
|
||||
validate_message = (search_data or {}).get("validate_message")
|
||||
|
||||
return {
|
||||
"resourceTitle": (search_data or {}).get("title", ""),
|
||||
"quality": ", ".join(resolution) if isinstance(resolution, list) else "",
|
||||
@@ -50,11 +59,10 @@ def normalize_resource(search_data, unlock_data):
|
||||
if isinstance(subtitle_language, list)
|
||||
else "",
|
||||
"slug": (search_data or {}).get("slug", ""),
|
||||
"unlockUrl": (unlock_data or {}).get("full_url")
|
||||
or (unlock_data or {}).get("url")
|
||||
or "",
|
||||
"availability": "available"
|
||||
if ((unlock_data or {}).get("full_url") or (unlock_data or {}).get("url"))
|
||||
else "unknown",
|
||||
"unlockUrl": unlock_url,
|
||||
"detailUrl": detail_url,
|
||||
"availability": "available" if unlock_url else ("index_only" if detail_url else "unknown"),
|
||||
"validateStatus": validate_status,
|
||||
"validateMessage": validate_message,
|
||||
"raw": {"searchData": search_data, "unlockData": unlock_data},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user