diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-10-26 20:15:12 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-10-26 20:27:09 +0530 |
commit | 48f796874d78ad3d1849d0639893667f6cdf30d2 (patch) | |
tree | b9c3d1c78bc085733599ee847c5bfd8654cf3aa2 /yt_dlp/YoutubeDL.py | |
parent | abad800058180da93f482915070aef12f8f63564 (diff) | |
download | hypervideo-pre-48f796874d78ad3d1849d0639893667f6cdf30d2.tar.lz hypervideo-pre-48f796874d78ad3d1849d0639893667f6cdf30d2.tar.xz hypervideo-pre-48f796874d78ad3d1849d0639893667f6cdf30d2.zip |
[utils] Create `DownloadCancelled` exception
as super-class of ExistingVideoReached, RejectedVideoReached, MaxDownloadsReached
Third parties can also sub-class this to cancel the download queue from a hook
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r-- | yt_dlp/YoutubeDL.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index ced7d1202..2c2b17b20 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -56,6 +56,7 @@ from .utils import ( DEFAULT_OUTTMPL, determine_ext, determine_protocol, + DownloadCancelled, DownloadError, encode_compat_str, encodeFilename, @@ -1320,7 +1321,7 @@ class YoutubeDL(object): self.to_stderr('\r') self.report_warning('The download speed is below throttle limit. Re-extracting data') return wrapper(self, *args, **kwargs) - except (MaxDownloadsReached, ExistingVideoReached, RejectedVideoReached, LazyList.IndexError): + except (DownloadCancelled, LazyList.IndexError): raise except Exception as e: if self.params.get('ignoreerrors'): @@ -2949,14 +2950,8 @@ class YoutubeDL(object): url, force_generic_extractor=self.params.get('force_generic_extractor', False)) except UnavailableVideoError: self.report_error('unable to download video') - except MaxDownloadsReached: - self.to_screen('[info] Maximum number of downloads reached') - raise - except ExistingVideoReached: - self.to_screen('[info] Encountered a video that is already in the archive, stopping due to --break-on-existing') - raise - except RejectedVideoReached: - self.to_screen('[info] Encountered a video that did not match filter, stopping due to --break-on-reject') + except DownloadCancelled as e: + self.to_screen(f'[info] {e.msg}') raise else: if self.params.get('dump_single_json', False): |