forked from DRMTalks/devine
Support CTRL+C on URL downloads, use FAILED/STOPPED messages
This commit is contained in:
parent
6a65617179
commit
3a98c93f03
|
@ -8,6 +8,7 @@ import re
|
|||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
from concurrent import futures
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from copy import deepcopy
|
||||
|
@ -756,6 +757,7 @@ class dl:
|
|||
)
|
||||
# no else-if as DASH may convert the track to URL descriptor
|
||||
if track.descriptor == track.Descriptor.URL:
|
||||
try:
|
||||
if not track.drm and isinstance(track, (Video, Audio)):
|
||||
# the service might not have explicitly defined the `drm` property
|
||||
# try find widevine DRM information from the init data of URL
|
||||
|
@ -784,6 +786,16 @@ class dl:
|
|||
track.drm = None
|
||||
if callable(track.OnDecrypted):
|
||||
track.OnDecrypted(track)
|
||||
except KeyboardInterrupt:
|
||||
progress(downloaded="[yellow]STOPPED")
|
||||
except Exception as e:
|
||||
progress(downloaded="[red]FAILED")
|
||||
traceback.print_exception(e)
|
||||
self.log.error(f"URL Download worker threw an unhandled exception: {e!r}")
|
||||
finally:
|
||||
self.DL_POOL_STOP.set()
|
||||
save_path.unlink(missing_ok=True)
|
||||
save_path.with_suffix(f"{save_path.suffix}.aria2").unlink(missing_ok=True)
|
||||
|
||||
if self.DL_POOL_STOP.is_set():
|
||||
# we stopped during the download, let's exit
|
||||
|
|
Loading…
Reference in New Issue