From 994f7c2443b062c3c2b958a37aec061ee2f1ae7f Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 10 Aug 2022 22:31:15 +0700 Subject: [PATCH] use user provided thumb for offline import --- tubearchivist/home/src/index/filesystem.py | 9 +++++++-- tubearchivist/home/src/index/video.py | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/src/index/filesystem.py b/tubearchivist/home/src/index/filesystem.py index 85e1c953..ac498303 100644 --- a/tubearchivist/home/src/index/filesystem.py +++ b/tubearchivist/home/src/index/filesystem.py @@ -476,8 +476,13 @@ class ManualImport: video.check_subtitles() video.upload_to_es() - url = video.json_data["vid_thumb_url"] - ThumbManager(video_id).download_video_thumb(url) + 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) + shutil.move(old_path, new_path, copy_function=shutil.copyfile) + else: + url = video.json_data["vid_thumb_url"] + ThumbManager(video_id).download_video_thumb(url) return video.json_data diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index 48c3eeb4..a2b54970 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -425,6 +425,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): self.channel_id = False self.video_overwrites = video_overwrites self.es_path = f"{self.index_name}/_doc/{youtube_id}" + self.offline_import = False def build_json(self, youtube_meta_overwrite=False, media_path=False): """build json dict of video""" @@ -434,6 +435,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): if not self.youtube_meta: self.youtube_meta = youtube_meta_overwrite + self.offline_import = True self._process_youtube_meta() self._add_channel()