From 099374ca0c22413f2bf2a8002dddb252bc98f4d0 Mon Sep 17 00:00:00 2001 From: stabbedbybrick <125766685+stabbedbybrick@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:54:16 +0200 Subject: [PATCH] fix(PLUTO): Fix year label for movies and series --- services/PLUTO/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/PLUTO/__init__.py b/services/PLUTO/__init__.py index f365fcf..f0d0cae 100644 --- a/services/PLUTO/__init__.py +++ b/services/PLUTO/__init__.py @@ -173,7 +173,7 @@ class PLUTO(Service): season=int(episode.get("season")), number=int(episode.get("number")), name=episode.get("name"), - year=None, + year=self.year(episode), language="en", # self.region, data=episode, ) @@ -194,10 +194,10 @@ class PLUTO(Service): Movie( id_=movie.get("_id"), service=self.__class__, - year=movie.get("slug", "").split("-")[-3], name=movie.get("name"), language="en", # self.region, data=movie, + year=self.year(movie), ) for movie in data ] @@ -280,3 +280,10 @@ class PLUTO(Service): ) return any(ad in text for ad in ads) + + @staticmethod + def year(data: dict) -> Optional[int]: + title_year = (int(match.group(1)) if (match := re.search(r"\((\d{4})\)", data.get("name", ""))) else None) + slug_year = (int(match.group(1)) if (match := re.search(r"\b(\d{4})\b", data.get("slug", ""))) else None) + return None if title_year else slug_year +