add fallback for none ascii channel names, #127 #146

This commit is contained in:
simon 2022-01-27 22:50:02 +07:00
parent 160676acc1
commit 0749202d5d
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 7 additions and 0 deletions

View File

@ -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):

View File

@ -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"]