Add movie-keyed pool index with multi-version movies, ČSFD title bridge, subtitles and miniDLNA library scoping
This commit is contained in:
@@ -26,6 +26,7 @@ class NfoData:
|
||||
countries: list[str] = field(default_factory=list)
|
||||
rating: Optional[int] = None # 0–100 (NFO 0–10 scaled up), or None
|
||||
tmdb_id: Optional[int] = None
|
||||
csfd_url: Optional[str] = None # ČSFD film URL, if the NFO carries a csfd id
|
||||
|
||||
def field_values(self, name: str) -> list[str]:
|
||||
"""Values for a tag-schema source field (genres/countries/year/rating)."""
|
||||
@@ -78,6 +79,29 @@ def _parse_tmdb_id(root: ET.Element) -> Optional[int]:
|
||||
return int(raw.strip()) if raw and raw.strip().isdigit() else None
|
||||
|
||||
|
||||
def _parse_csfd_url(root: ET.Element) -> Optional[str]:
|
||||
"""A ČSFD film URL from the NFO, if any.
|
||||
|
||||
Czech Kodi scrapers record ČSFD as ``<uniqueid type="csfd">`` (a bare id or a
|
||||
full URL) or a legacy ``<csfdid>`` / ``<csfd>`` element. A bare id is expanded
|
||||
to ``https://www.csfd.cz/film/<id>/``.
|
||||
"""
|
||||
candidates: list[str] = []
|
||||
for uid in root.findall("uniqueid"):
|
||||
if uid.get("type") == "csfd" and uid.text and uid.text.strip():
|
||||
candidates.append(uid.text.strip())
|
||||
for tag in ("csfdid", "csfd"):
|
||||
raw = root.findtext(tag)
|
||||
if raw and raw.strip():
|
||||
candidates.append(raw.strip())
|
||||
for value in candidates:
|
||||
if value.isdigit():
|
||||
return f"https://www.csfd.cz/film/{value}/"
|
||||
if "csfd.cz" in value:
|
||||
return value if value.startswith("http") else f"https://{value.lstrip('/')}"
|
||||
return None
|
||||
|
||||
|
||||
def read_nfo(video_path: Path) -> Optional[NfoData]:
|
||||
"""Read the movie's ``.nfo`` into :class:`NfoData`, or None if absent/broken."""
|
||||
path = find_nfo(video_path)
|
||||
@@ -98,4 +122,5 @@ def read_nfo(video_path: Path) -> Optional[NfoData]:
|
||||
countries=_texts(root, "country"),
|
||||
rating=_parse_rating(root),
|
||||
tmdb_id=_parse_tmdb_id(root),
|
||||
csfd_url=_parse_csfd_url(root),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user