From 0749202d5df6ad3cd6699b170949449d2c264409 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 27 Jan 2022 22:50:02 +0700 Subject: [PATCH] add fallback for none ascii channel names, #127 #146 --- tubearchivist/home/src/download/yt_dlp_handler.py | 3 +++ tubearchivist/home/src/index/video.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tubearchivist/home/src/download/yt_dlp_handler.py b/tubearchivist/home/src/download/yt_dlp_handler.py index 6d17a33..be71049 100644 --- a/tubearchivist/home/src/download/yt_dlp_handler.py +++ b/tubearchivist/home/src/download/yt_dlp_handler.py @@ -212,6 +212,9 @@ class VideoDownloader: host_uid = self.config["application"]["HOST_UID"] host_gid = self.config["application"]["HOST_GID"] channel_name = clean_string(vid_dict["channel"]["channel_name"]) + if len(channel_name) <= 3: + # fall back to channel id + channel_name = vid_dict["channel"]["channel_id"] # make archive folder with correct permissions new_folder = os.path.join(videos, channel_name) if not os.path.exists(new_folder): diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index 240a1b3..00db3f6 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -125,6 +125,10 @@ class YoutubeVideo(YouTubeItem): """build media_url for where file will be located""" channel_name = self.json_data["channel"]["channel_name"] clean_channel_name = clean_string(channel_name) + if len(clean_channel_name) <= 3: + # fall back to channel id + clean_channel_name = self.json_data["channel"]["channel_id"] + timestamp = self.json_data["published"].replace("-", "") youtube_id = self.json_data["youtube_id"] title = self.json_data["title"]