This commit is contained in:
parent
7e6a13f466
commit
44122a8ef4
|
@ -36,7 +36,7 @@ parser.add_argument('--rm-cache', '-r', action='store_true', help='Delete the yt
|
|||
parser.add_argument('--threads', type=int, default=cpu_count(), help='How many download processes to use.')
|
||||
parser.add_argument('--daemon', '-d', action='store_true', help="Run in daemon mode. Disables progress bars sleeps for the amount of time specified in --sleep.")
|
||||
parser.add_argument('--sleep', type=float, default=60, help='How many minutes to sleep when in daemon mode.')
|
||||
parser.add_argument('--silence-errors', '-s', action='store_true', help="Don't print any error messages to the console. Does not do anything in daemon mode.")
|
||||
parser.add_argument('--silence-errors', '-s', action='store_true', help="Don't print any error messages to the console.")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.threads <= 0:
|
||||
|
@ -207,6 +207,7 @@ while True:
|
|||
logger.info('Fetching playlist...')
|
||||
playlist = yt_dlp.playlist_contents(target_url)
|
||||
playlist['entries'] = remove_duplicates_from_playlist(playlist['entries'])
|
||||
encountered_errors = 0
|
||||
|
||||
log_info_twice(f"Downloading item: '{playlist['title']}' {target_url}")
|
||||
|
||||
|
@ -233,7 +234,7 @@ while True:
|
|||
((video, {
|
||||
'bars': video_bars,
|
||||
'ydl_opts': ydl_opts,
|
||||
'output_dir': args.output
|
||||
'output_dir': args.output,
|
||||
}) for video in download_queue)):
|
||||
# Save the video ID to the file
|
||||
if result['downloaded_video_id']:
|
||||
|
@ -242,9 +243,15 @@ while True:
|
|||
# Print stuff
|
||||
for line in result['video_error_logger_msg']:
|
||||
video_error_logger.info(line)
|
||||
log_info_twice(line)
|
||||
if not args.silence_errors and not args.daemon:
|
||||
playlist_bar.write(line)
|
||||
logger.error(line)
|
||||
file_logger.error(line)
|
||||
encountered_errors += 1
|
||||
if not args.silence_errors:
|
||||
if args.daemon:
|
||||
logger.error(line)
|
||||
else:
|
||||
playlist_bar.write(line)
|
||||
|
||||
# for line in result['status_msg']:
|
||||
# playlist_bar.write(line)
|
||||
for line in result['logger_msg']:
|
||||
|
@ -252,13 +259,21 @@ while True:
|
|||
playlist_bar.update()
|
||||
else:
|
||||
playlist_bar.write(f"All videos already downloaded for '{playlist['title']}'.")
|
||||
error_msg = f'Encountered {encountered_errors} errors.'
|
||||
if args.daemon:
|
||||
logger.info(error_msg)
|
||||
else:
|
||||
playlist_bar.write(error_msg)
|
||||
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.")
|
||||
if not args.daemon:
|
||||
break
|
||||
else:
|
||||
logger.info(f'Sleeping for {args.sleep} min.')
|
||||
time.sleep(args.sleep * 60)
|
||||
try:
|
||||
time.sleep(args.sleep * 60)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit()
|
||||
downloaded_videos = load_existing_videos() # reload the videos that have already been downloaded
|
||||
|
||||
# Erase the status bar.
|
||||
|
|
|
@ -95,7 +95,7 @@ def download_video(args) -> dict:
|
|||
# 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"{video['id']} {video['title']} -> {e}")
|
||||
output_dict['video_error_logger_msg'].append(f"EXCEPTION -> {e}")
|
||||
if locked:
|
||||
bar.close()
|
||||
bar_lock.release()
|
||||
|
|
Reference in New Issue