fix other issues?
This commit is contained in:
parent
ff7b7205d1
commit
38620c5eba
|
@ -10,7 +10,8 @@ from pathlib import Path
|
|||
from threading import Thread
|
||||
|
||||
import numpy as np
|
||||
# import yt_dlp as ydl_ydl
|
||||
import yt_dlp as ydl_ydl
|
||||
from hurry.filesize import size
|
||||
from tqdm.auto import tqdm
|
||||
from unidecode import unidecode
|
||||
|
||||
|
@ -80,10 +81,15 @@ def download_video(args) -> dict:
|
|||
if total > 0:
|
||||
percent = (downloaded_bytes / total) * 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"{size(d.get('downloaded_bytes'))}/{size(total)}",
|
||||
})
|
||||
else:
|
||||
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]
|
||||
|
@ -156,10 +162,10 @@ def download_video(args) -> dict:
|
|||
# base_path = kwargs['output_dir'] / video['id']
|
||||
ylogger = ytdl_logger(setup_file_logger(video['id'], base_path + '.log'))
|
||||
kwargs['ydl_opts']['logger'] = ylogger
|
||||
# with ydl_ydl.YoutubeDL(kwargs['ydl_opts']) as y:
|
||||
# error_code = y.download(video['url'])
|
||||
yt_dlp = ydl.YDL(kwargs['ydl_opts']) # recreate the object with the correct logging path
|
||||
error_code = yt_dlp(video['url']) # Do the download
|
||||
with ydl_ydl.YoutubeDL(kwargs['ydl_opts']) as y:
|
||||
error_code = y.download(video['url'])
|
||||
# yt_dlp = ydl.YDL(kwargs['ydl_opts']) # recreate the object with the correct logging path
|
||||
# error_code = yt_dlp(video['url']) # Do the download
|
||||
if not error_code:
|
||||
elapsed = round(math.ceil(time.time() - start_time) / 60, 2)
|
||||
output_dict['logger_msg'].append(f"'{video['title']}' - Downloaded in {elapsed} min.")
|
||||
|
|
Reference in New Issue