diff --git a/process/threads.py b/process/threads.py index 5b902a3..3b89c6c 100644 --- a/process/threads.py +++ b/process/threads.py @@ -46,8 +46,8 @@ def download_video(args) -> dict: yt_dlp = ydl.YDL(ydl_opts) # Get a bar + locked = False if len(bars): - locked = False # We're going to wait until a bar is available for us to use. while not locked: for item in bars: @@ -57,10 +57,9 @@ def download_video(args) -> dict: bar_lock = item[1] break - width, _ = os.get_terminal_size() - desc_with = int(np.round(width * (1 / 4))) + desc_with = int(np.round(os.get_terminal_size()[0] * (1 / 4))) bar = tqdm(total=100, position=(offset if len(bars) 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)) - output_dict = {'downloaded_video_id': None, 'video_error_logger_msg': [], 'status_msg': [], 'logger_msg': []} # empty object + output_dict = {'downloaded_video_id': None, 'blacklist_video_id': None, 'video_error_logger_msg': [], 'status_msg': [], 'logger_msg': []} # empty object start_time = time.time() try: @@ -76,10 +75,6 @@ def download_video(args) -> dict: except Exception as e: output_dict['video_error_logger_msg'].append(f"{video['id']} {video['title']} -> {e}") bar.close() - try: + if locked: bar_lock.release() - except UnboundLocalError: - pass - except NameError: - pass return output_dict