diff --git a/downloader.py b/downloader.py index c7b9c2f..d90a0b1 100755 --- a/downloader.py +++ b/downloader.py @@ -189,14 +189,14 @@ for i, target_url in tqdm(enumerate(url_list), total=len(url_list), position=0, log_info_twice(f"Downloading item: '{playlist['title']}' {target_url}") - playlist_bar.total = len(download_queue) + playlist_bar.total = len(playlist['entries']) playlist_bar.set_description(playlist['title']) # Remove already downloaded files from the to-do list. for p, video in enumerate(download_queue): if video['id'] in downloaded_videos: del download_queue[p] - playlist_bar.update(len(download_queue)) + playlist_bar.update(len(downloaded_videos)) if len(download_queue): # Don't mess with multiprocessing if all videos are already downloaded with Pool(processes=args.threads) as pool: @@ -208,8 +208,6 @@ for i, target_url in tqdm(enumerate(url_list), total=len(url_list), position=0, 'download_archive': downloaded_videos, 'ydl_opts': thread_opts, }) for video in download_queue)): - print(result) - # Save the video ID to the file if result['downloaded_video_id']: download_archive_logger.info(result['downloaded_video_id']) diff --git a/process/threads.py b/process/threads.py index 65b7812..dc792b1 100644 --- a/process/threads.py +++ b/process/threads.py @@ -40,10 +40,7 @@ def download_video(args) -> dict: video = args[0] kwargs = args[1] bars = kwargs['bars'] - ydl_opts = kwargs['ydl_opts'] - ydl_opts['progress_hooks'] = [progress_hook] - yt_dlp = ydl.YDL(ydl_opts) # Get a bar locked = False @@ -56,6 +53,9 @@ def download_video(args) -> dict: offset = item[0] bar_lock = item[1] break + ydl_opts['progress_hooks'] = [progress_hook] + + yt_dlp = ydl.YDL(ydl_opts) desc_with = int(np.round(os.get_terminal_size()[0] * (1 / 4))) bar = tqdm(total=100, position=(offset if locked else None), desc=video['title'].ljust(desc_with)[:desc_with], bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}{postfix}]', leave=False, disable=not len(bars))