fix file path errors, change log format group files together
This commit is contained in:
parent
933ab8301a
commit
f593b93ab5
|
@ -126,8 +126,8 @@ create_directories(args.log_dir)
|
|||
|
||||
# TODO: log file rotation https://www.blog.pythonlibrary.org/2014/02/11/python-how-to-create-rotating-logs/
|
||||
# TODO: log to one file instead of one for each run
|
||||
file_logger = setup_file_logger('youtube_dl', args.log_dir / f'youtube_dl-{str(int(log_time))}.log', level=logging.INFO)
|
||||
video_error_logger = setup_file_logger('youtube_dl_video_errors', args.log_dir / f'youtube_dl-errors-{int(log_time)}.log', level=logging.INFO)
|
||||
file_logger = setup_file_logger('youtube_dl', args.log_dir / f'{str(int(log_time))}.log', level=logging.INFO)
|
||||
video_error_logger = setup_file_logger('youtube_dl_video_errors', args.log_dir / f'{int(log_time)}-errors.log', level=logging.INFO)
|
||||
logger = get_silent_logger('yt-dl', silent=not args.daemon)
|
||||
|
||||
|
||||
|
@ -294,7 +294,7 @@ while True:
|
|||
playlist_bar.update(len(downloaded_videos))
|
||||
|
||||
playlist_ydl_opts = ydl_opts.copy()
|
||||
playlist_ydl_opts['outtmpl'] = f'{output_path}/{base_outtempl}',
|
||||
playlist_ydl_opts['outtmpl'] = f'{output_path}/{base_outtempl}'
|
||||
|
||||
if len(download_queue): # Don't mess with multiprocessing if all videos are already downloaded
|
||||
with Pool(processes=args.threads) as pool:
|
||||
|
|
|
@ -63,7 +63,6 @@ def download_video(args) -> dict:
|
|||
bar.set_postfix({
|
||||
'speed': d['_speed_str'],
|
||||
'size': f"{d['_downloaded_bytes_str'].strip()}/{d['_total_bytes_str'].strip()}",
|
||||
'offset': offset
|
||||
})
|
||||
|
||||
video = args[0]
|
||||
|
@ -76,7 +75,7 @@ def download_video(args) -> dict:
|
|||
while not locked:
|
||||
for item in kwargs['bars']:
|
||||
if not is_manager_lock_locked(item[1]):
|
||||
locked = item[1].acquire(timeout=0.2) # get the lock ASAP and don't wait if we didn't get it.
|
||||
locked = item[1].acquire(timeout=0.1) # get the lock ASAP and don't wait if we didn't get it.
|
||||
offset = item[0]
|
||||
bar_lock = item[1]
|
||||
break
|
||||
|
@ -93,7 +92,7 @@ def download_video(args) -> dict:
|
|||
try:
|
||||
base_path = os.path.splitext(yt_dlp.prepare_filename(yt_dlp.extract_info(video['url'], download=False)))[0]
|
||||
except AttributeError:
|
||||
# Sometimes we won't be able to pull the video info so just use the video's ID
|
||||
# Sometimes we won't be able to pull the video info so just use the video's ID.
|
||||
base_path = kwargs['output_dir'] / video['id']
|
||||
ylogger = ytdl_logger(setup_file_logger(video['id'], str(base_path) + '.log'))
|
||||
kwargs['ydl_opts']['logger'] = ylogger
|
||||
|
@ -104,9 +103,6 @@ def download_video(args) -> dict:
|
|||
output_dict['logger_msg'].append(f"{video['id']} '{video['title']}' downloaded in {elapsed} min.")
|
||||
output_dict['downloaded_video_id'] = video['id']
|
||||
else:
|
||||
# m = f'{video["id"]} {video["title"]} -> Failed to download, error code: {error_code}'
|
||||
# output_dict['status_msg'].append(m)
|
||||
# output_dict['video_error_logger_msg'].append(m)
|
||||
output_dict['video_error_logger_msg'] = output_dict['video_error_logger_msg'] + ylogger.errors
|
||||
except Exception as e:
|
||||
output_dict['video_error_logger_msg'].append(f"EXCEPTION -> {e}")
|
||||
|
|
Reference in New Issue