use user provided thumb for offline import

This commit is contained in:
simon 2022-08-10 22:31:15 +07:00
parent 7029441f89
commit 994f7c2443
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 9 additions and 2 deletions

View File

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

View File

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