Print a download cancelled message on CTRL+C

This commit is contained in:
rlaphoenix 2023-02-28 17:03:25 +00:00
parent 53c005f727
commit ad1990cc42
1 changed files with 16 additions and 13 deletions

View File

@ -433,16 +433,16 @@ class dl:
if skip_dl: if skip_dl:
self.log.info("Skipping Download...") self.log.info("Skipping Download...")
else: else:
with Live( try:
Padding( with Live(
download_table, Padding(
(1, 5) download_table,
), (1, 5)
console=console, ),
refresh_per_second=5 console=console,
): refresh_per_second=5
with ThreadPoolExecutor(workers) as pool: ):
try: with ThreadPoolExecutor(workers) as pool:
for download in futures.as_completed(( for download in futures.as_completed((
pool.submit( pool.submit(
self.download_track, self.download_track,
@ -480,9 +480,12 @@ class dl:
self.log.error("Download worker threw an unhandled exception:") self.log.error("Download worker threw an unhandled exception:")
console.print_exception() console.print_exception()
return return
except KeyboardInterrupt: except KeyboardInterrupt:
self.log.info("Received Keyboard Interrupt, stopping...") console.print(Padding(
return ":x: Download Cancelled...",
(0, 5, 1, 5)
))
return
video_track_n = 0 video_track_n = 0