From de493cb181bec8babb8358f94cbfa4135e2e0aa5 Mon Sep 17 00:00:00 2001 From: stabbedbybrick <125766685+stabbedbybrick@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:39:54 +0200 Subject: [PATCH] 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. --- services/ITV/__init__.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/services/ITV/__init__.py b/services/ITV/__init__.py index 3d0dc3e..e084a89 100644 --- a/services/ITV/__init__.py +++ b/services/ITV/__init__.py @@ -36,6 +36,8 @@ class ITV(Service): SERIES: https://www.itv.com/watch/bay-of-fires/10a5270 EPISODE: https://www.itv.com/watch/bay-of-fires/10a5270/10a5270a0001 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 Examples: @@ -155,7 +157,30 @@ class ITV(Service): def get_titles(self) -> Union[Movies, Series]: 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"): episode = data.get("episode")