From cf92884eb21e7aa3aa58be2472c80b2adfb08646 Mon Sep 17 00:00:00 2001 From: Simon Fischer Date: Tue, 20 Jun 2023 20:48:52 +0200 Subject: [PATCH 1/2] workaround crash for empty channels --- src/series.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/series.py b/src/series.py index e4c1b25..db5e3c5 100644 --- a/src/series.py +++ b/src/series.py @@ -155,13 +155,18 @@ class Show: def validate_show(self) -> None: """set show metadata""" - ta_channel: TAChannel = self._get_ta_channel() + ta_channel: TAChannel | None = self._get_ta_channel() + if ta_channel is None: + return self.update_metadata(ta_channel) self.update_artwork(ta_channel) - def _get_ta_channel(self) -> TAChannel: + def _get_ta_channel(self) -> TAChannel | None: """get ta channel metadata""" - episode: JFEpisode = self._get_all_episodes(limit=1)[0] + episodes: list[JFEpisode] = self._get_all_episodes(limit=1) + if(len(episodes) == 0): + return None + episode: JFEpisode = episodes[0] youtube_id: str = os.path.split(episode["Path"])[-1][9:20] path = f"/video/{youtube_id}" From 12d9d394b7319ff24107f87c6ae6c8e8cb8fdb6c Mon Sep 17 00:00:00 2001 From: Simon Fischer Date: Wed, 28 Jun 2023 14:27:52 +0200 Subject: [PATCH 2/2] update requested condition, add jetbrains editors to gitignore --- .gitignore | 1 + src/series.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 31cb477..de5c7c1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ __pycache__ # editor .vscode +.idea diff --git a/src/series.py b/src/series.py index db5e3c5..74b4478 100644 --- a/src/series.py +++ b/src/series.py @@ -164,8 +164,8 @@ class Show: def _get_ta_channel(self) -> TAChannel | None: """get ta channel metadata""" episodes: list[JFEpisode] = self._get_all_episodes(limit=1) - if(len(episodes) == 0): - return None + if not episodes: + return episode: JFEpisode = episodes[0] youtube_id: str = os.path.split(episode["Path"])[-1][9:20] path = f"/video/{youtube_id}"