diff --git a/src/connect.py b/src/connect.py index 7530177..b7ac72d 100644 --- a/src/connect.py +++ b/src/connect.py @@ -105,3 +105,13 @@ def env_check() -> None: if not os.path.exists(CONFIG["ta_video_path"]): raise FileNotFoundError("failed to access ta_video_path") + + +def clean_overview(overview_raw: str) -> str: + """parse and clean raw overview text""" + if len(overview_raw) > 500: + overview_raw = overview_raw[:500] + " ..." + + desc_clean: str = overview_raw.replace("\n", "
") + + return desc_clean diff --git a/src/episode.py b/src/episode.py index 0ef6997..3395bcf 100644 --- a/src/episode.py +++ b/src/episode.py @@ -2,7 +2,7 @@ from datetime import datetime -from src.connect import Jellyfin, TubeArchivist +from src.connect import Jellyfin, TubeArchivist, clean_overview from src.static_types import TAVideo @@ -58,8 +58,5 @@ class Episode: if not raw_desc: return False - desc_clean: str = raw_desc.replace("\n", "
") - if len(raw_desc) > 500: - return desc_clean[:500] + " ..." - + desc_clean: str = clean_overview(raw_desc) return desc_clean diff --git a/src/series.py b/src/series.py index 55dfe42..c9e1868 100644 --- a/src/series.py +++ b/src/series.py @@ -5,7 +5,7 @@ import os from time import sleep from src.config import get_config -from src.connect import Jellyfin, TubeArchivist +from src.connect import Jellyfin, TubeArchivist, clean_overview from src.episode import Episode from src.static_types import JFEpisode, JFShow, TAChannel, TAVideo @@ -172,16 +172,26 @@ class Show: def update_metadata(self, ta_channel: TAChannel) -> None: """update channel metadata""" path: str = "Items/" + self.show["Id"] - data = { + data: dict = { "Id": self.show["Id"], "Name": ta_channel["channel_name"], - "Overview": ta_channel["channel_description"], + "Overview": self._get_desc(ta_channel), "Genres": [], "Tags": [], "ProviderIds": {}, } Jellyfin().post(path, data) + def _get_desc(self, ta_channel: TAChannel) -> str | bool: + """get parsed description""" + raw_desc: str = ta_channel["channel_description"] + if not raw_desc: + return False + + desc_clean: str = clean_overview(raw_desc) + + return desc_clean + def update_artwork(self, ta_channel: TAChannel) -> None: """set channel artwork""" jf_id: str = self.show["Id"] @@ -205,7 +215,7 @@ class Show: print(f"[show][{showname}] no new videos found") return - print(f"[show][{showname}] found {len(new_episodes)} new videos") + print(f"[show][{showname}] indexing {len(new_episodes)} videos") for video in new_episodes: youtube_id: str = os.path.split(video["Path"])[-1][9:20] Episode(youtube_id, video["Id"]).sync()