From 3d18761f620a294ea6c5bff13c5994b93b29f3ed Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 16 Aug 2025 07:00:33 -0400 Subject: New upstream version 1.30.3. --- gallery_dl/exception.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'gallery_dl/exception.py') diff --git a/gallery_dl/exception.py b/gallery_dl/exception.py index 5a52581..6adda0d 100644 --- a/gallery_dl/exception.py +++ b/gallery_dl/exception.py @@ -100,12 +100,17 @@ class AuthorizationError(ExtractionError): class AuthRequired(AuthorizationError): default = "Account credentials required" - def __init__(self, required=None, message=None): - if required and not message: - if isinstance(required, str): - message = f"{required} required" + def __init__(self, auth=None, resource="resource", message=None): + if auth: + if not isinstance(auth, str): + auth = " or ".join(auth) + if " " not in resource: + resource = "this " + resource + if message is None: + message = (f"{auth} needed to access {resource}") else: - message = f"{' or '.join(required)} required" + message = (f"{auth} needed to access {resource} " + f"('{message}')") AuthorizationError.__init__(self, message) @@ -160,6 +165,22 @@ class ControlException(GalleryDLException): class StopExtraction(ControlException): """Stop data extraction""" + def __init__(self, target=None): + ControlException.__init__(self) + + if target is None: + self.target = None + self.depth = 1 + elif isinstance(target, int): + self.target = None + self.depth = target + elif target.isdecimal(): + self.target = None + self.depth = int(target) + else: + self.target = target + self.depth = 128 + class AbortExtraction(ExtractionError, ControlException): """Abort data extraction due to an error""" -- cgit v1.2.3