fix(ITV): Fix seriesType for shows without any type

- Some shows (reality, entertainment) aren't listed as "Series", only as "Latest episodes". These are now handled as their own Series object and should be downloaded by the series URL, not episode URL.
This commit is contained in:
stabbedbybrick 2024-06-02 21:39:54 +02:00
parent 013c5f028c
commit de493cb181

View File

@ -36,6 +36,8 @@ class ITV(Service):
SERIES: https://www.itv.com/watch/bay-of-fires/10a5270 SERIES: https://www.itv.com/watch/bay-of-fires/10a5270
EPISODE: https://www.itv.com/watch/bay-of-fires/10a5270/10a5270a0001 EPISODE: https://www.itv.com/watch/bay-of-fires/10a5270/10a5270a0001
FILM: https://www.itv.com/watch/mad-max-beyond-thunderdome/2a7095 FILM: https://www.itv.com/watch/mad-max-beyond-thunderdome/2a7095
- Some shows aren't listed as series, only as "Latest episodes"
Download by SERIES URL for those titles, not by EPISODE URL
\b \b
Examples: Examples:
@ -155,7 +157,30 @@ class ITV(Service):
def get_titles(self) -> Union[Movies, Series]: def get_titles(self) -> Union[Movies, Series]:
data = self.get_data(self.title) data = self.get_data(self.title)
kind = data["seriesList"][0]["seriesType"] kind = next(
(x.get("seriesType") for x in data.get("seriesList") if x.get("seriesType") in ["SERIES", "FILM"]), None
)
# Some shows are not listed as "SERIES" or "FILM", only as "Latest episodes"
if not kind and next(
(x for x in data.get("seriesList") if x.get("seriesLabel").lower() == "latest episodes"), None
):
titles = data["seriesList"][0]["titles"]
return Series(
[
Episode(
id_=episode["episodeId"],
service=self.__class__,
title=data["programme"]["title"],
season=episode.get("series") if isinstance(episode.get("series"), int) else 0,
number=episode.get("episode") if isinstance(episode.get("episode"), int) else 0,
name=episode["episodeTitle"],
language="en", # TODO: language detection
data=episode,
)
for episode in titles
]
)
if kind == "SERIES" and data.get("episode"): if kind == "SERIES" and data.get("episode"):
episode = data.get("episode") episode = data.get("episode")