From 1c3febc49dee7366eff6b67f37403c93f1ae9507 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 6 Sep 2022 23:13:29 +0700 Subject: [PATCH] force create thumb folder for manual import --- tubearchivist/home/src/download/thumbnails.py | 6 +++++- tubearchivist/home/src/index/filesystem.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/src/download/thumbnails.py b/tubearchivist/home/src/download/thumbnails.py index 4e77453f..ff556c09 100644 --- a/tubearchivist/home/src/download/thumbnails.py +++ b/tubearchivist/home/src/download/thumbnails.py @@ -124,7 +124,7 @@ class ThumbManager(ThumbManagerBase): img_raw.convert("RGB").save(thumb_path) - def vid_thumb_path(self, absolute=False): + def vid_thumb_path(self, absolute=False, create_folder=False): """build expected path for video thumbnail from youtube_id""" folder_name = self.item_id[0].lower() folder_path = os.path.join("videos", folder_name) @@ -132,6 +132,10 @@ class ThumbManager(ThumbManagerBase): if absolute: thumb_path = os.path.join(self.CACHE_DIR, thumb_path) + if create_folder: + folder_path = os.path.join(self.CACHE_DIR, folder_path) + os.makedirs(folder_path, exist_ok=True) + return thumb_path def download_channel_art(self, urls, skip_existing=False): diff --git a/tubearchivist/home/src/index/filesystem.py b/tubearchivist/home/src/index/filesystem.py index 768d7137..bbe69fc4 100644 --- a/tubearchivist/home/src/index/filesystem.py +++ b/tubearchivist/home/src/index/filesystem.py @@ -527,7 +527,8 @@ class ManualImport: if video.offline_import and self.current_video["thumb"]: old_path = self.current_video["thumb"] - new_path = ThumbManager(video_id).vid_thumb_path(absolute=True) + thumbs = ThumbManager(video_id) + new_path = thumbs.vid_thumb_path(absolute=True, create_folder=True) shutil.move(old_path, new_path, copy_function=shutil.copyfile) else: url = video.json_data["vid_thumb_url"]