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/utils.py | |
parent | abad800058180da93f482915070aef12f8f63564 (diff) |
[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/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 9d90eca5e..a8755a1b9 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -2542,23 +2542,33 @@ class PostProcessingError(YoutubeDLError): self.msg = msg -class ExistingVideoReached(YoutubeDLError): - """ --max-downloads limit has been reached. """ - pass +class DownloadCancelled(YoutubeDLError): + """ Exception raised when the download queue should be interrupted """ + msg = 'The download was cancelled' + def __init__(self, msg=None): + if msg is not None: + self.msg = msg + YoutubeDLError.__init__(self, self.msg) -class RejectedVideoReached(YoutubeDLError): - """ --max-downloads limit has been reached. """ - pass +class ExistingVideoReached(DownloadCancelled): + """ --break-on-existing triggered """ + msg = 'Encountered a video that is already in the archive, stopping due to --break-on-existing' -class ThrottledDownload(YoutubeDLError): - """ Download speed below --throttled-rate. """ - pass + +class RejectedVideoReached(DownloadCancelled): + """ --break-on-reject triggered """ + msg = 'Encountered a video that did not match filter, stopping due to --break-on-reject' -class MaxDownloadsReached(YoutubeDLError): +class MaxDownloadsReached(DownloadCancelled): """ --max-downloads limit has been reached. """ + msg = 'Maximum number of downloads reached, stopping due to --max-downloads' + + +class ThrottledDownload(YoutubeDLError): + """ Download speed below --throttled-rate. """ pass |