This commit is contained in:
Cyberes 2023-01-21 15:35:33 -07:00
parent f3877911a8
commit 5494ada801
No known key found for this signature in database
GPG Key ID: 194A1C358AACFC39
1 changed files with 7 additions and 8 deletions

View File

@ -32,10 +32,10 @@ def download_video(args) -> dict:
if total_bytes > 0:
percent = (downloaded_bytes / total_bytes) * 100
bar.update(int(np.round(percent - bar.n))) # If the progress bar doesn't end at 100% then round to 1 decimal place
bar.set_postfix({
'speed': d['_speed_str'],
'size': f"{d['_downloaded_bytes_str'].strip()}/{d['_total_bytes_str'].strip()}",
})
bar.set_postfix({
'speed': d['_speed_str'],
'size': f"{d['_downloaded_bytes_str'].strip()}/{d['_total_bytes_str'].strip()}",
})
video = args[0]
kwargs = args[1]
@ -54,11 +54,10 @@ def download_video(args) -> dict:
bar_lock = item[1]
break
ydl_opts['progress_hooks'] = [progress_hook]
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))
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))
output_dict = {'downloaded_video_id': None, 'blacklist_video_id': None, 'video_error_logger_msg': [], 'status_msg': [], 'logger_msg': []} # empty object
start_time = time.time()
@ -74,7 +73,7 @@ def download_video(args) -> dict:
output_dict['video_error_logger_msg'].append(m)
except Exception as e:
output_dict['video_error_logger_msg'].append(f"{video['id']} {video['title']} -> {e}")
bar.close()
if locked:
bar.close()
bar_lock.release()
return output_dict