This commit is contained in:
Cyberes 2023-01-21 15:03:06 -07:00
parent b38532926b
commit 565465928f
No known key found for this signature in database
GPG Key ID: 194A1C358AACFC39
1 changed files with 11 additions and 9 deletions

View File

@ -74,7 +74,13 @@ file_logger = setup_file_logger('youtube_dl', log_dir / f'youtube_dl-{str(int(lo
video_error_logger = setup_file_logger('youtube_dl_video_errors', log_dir / f'youtube_dl-errors-{int(log_time)}.log', level=logging.INFO)
logger = get_silent_logger('yt-dl', silent=not args.daemon)
file_logger.info(f'Starting process.')
def log_info_twice(msg):
logger.info(msg)
file_logger.info(msg)
log_info_twice('Starting process.')
start_time = time.time()
manager = Manager()
@ -98,11 +104,6 @@ def log_bar(msg, level):
status_bar.write(f'[{level}] {msg}')
def log_info_twice(msg):
logger.info(msg)
file_logger.info(msg)
def print_without_paths(msg):
"""
Remove any filepaths or other stuff we don't want in the message.
@ -176,10 +177,11 @@ if args.daemon:
])
for i, target_url in tqdm(enumerate(url_list), total=len(url_list), position=0, desc='Inputs', disable=not args.daemon):
logger.info('Fetching playlist...')
playlist = yt_dlp.playlist_contents(target_url)
download_queue = playlist['entries']
file_logger.info(f"Downloading item: '{playlist['title']}' {target_url}")
log_info_twice(f"Downloading item: '{playlist['title']}' {target_url}")
playlist_bar.total = len(download_queue)
playlist_bar.set_description(playlist['title'])
@ -216,8 +218,8 @@ for i, target_url in tqdm(enumerate(url_list), total=len(url_list), position=0,
playlist_bar.update()
else:
playlist_bar.write(f"All videos already downloaded for '{playlist['title']}'")
file_logger.info(f"Finished item: '{playlist['title']}' {target_url}")
file_logger.info(f"Finished process in {round(math.ceil(time.time() - start_time) / 60, 2)} min.")
log_info_twice(f"Finished item: '{playlist['title']}' {target_url}")
log_info_twice(f"Finished process in {round(math.ceil(time.time() - start_time) / 60, 2)} min.")
# Erase the status bar.
status_bar.set_description_str('\x1b[2KDone!')