feat(api): expose optional account-scoped title availability

This commit is contained in:
Jakub Rybakowski
2026-11-23 18:54:36 -06:00
committed by GitHub
parent c818ec3bbe
commit 661be3ee0d
6 changed files with 104 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
"""Public, account-scoped availability metadata supplied by a service.
Keep this allowlist separate from title.data: that dict can contain credentials,
playback URLs and other private service state which must never cross the API.
"""
from typing import Any, Dict, Optional
def availability_metadata(value: Any) -> Optional[Dict[str, Any]]:
"""Return only well-typed display fields; absent metadata remains absent."""
if not isinstance(value, dict):
return None
result: Dict[str, Any] = {}
if isinstance(value.get("paid"), bool):
result["paid"] = value["paid"]
access = value.get("access")
if isinstance(access, str) and access in ("granted", "denied", "unknown"):
result["access"] = access
return result or None