From ba12c2ad25458f4616a3e5d23717845531d61e5d Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 14 Oct 2021 21:28:27 +0700 Subject: [PATCH] simple progress message for thumbnail bulk download --- tubearchivist/home/src/thumbnails.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/src/thumbnails.py b/tubearchivist/home/src/thumbnails.py index 6feccea..ffff3d8 100644 --- a/tubearchivist/home/src/thumbnails.py +++ b/tubearchivist/home/src/thumbnails.py @@ -97,7 +97,12 @@ class ThumbManager: def get_raw_img(self, img_url, thumb_type): """get raw image from youtube and handle 404""" - app_root = self.CONFIG["application"]["app_root"] + try: + app_root = self.CONFIG["application"]["app_root"] + except KeyError: + # lazy keyerror fix to not have to deal with a strange startup + # racing contition between the threads in HomeConfig.ready() + app_root = "/app" default_map = { "video": os.path.join( app_root, "static/img/default-video-thumb.jpg" @@ -129,8 +134,11 @@ class ThumbManager: def download_vid(self, missing_thumbs): """download all missing thumbnails from list""" - print(f"downloading {len(missing_thumbs)} thumbnails") + total = len(missing_thumbs) + print(f"downloading {total} thumbnails") # videos + # counter as update path from v0.0.5, remove in future version + counter = 0 for youtube_id, thumb_url in missing_thumbs: folder_name = youtube_id[0].lower() folder_path = os.path.join(self.VIDEO_DIR, folder_name) @@ -155,6 +163,9 @@ class ThumbManager: "message": "Downloading Thumbnails...", } RedisArchivist().set_message("progress:download", mess_dict) + if counter % 50 == 0 and counter != 0: + print(f"thumbnail progress: {counter}/{total}") + counter = counter + 1 def download_chan(self, missing_channels): """download needed artwork for channels"""