diff options
| author | 2025-08-16 07:00:33 -0400 | |
|---|---|---|
| committer | 2025-08-16 07:00:33 -0400 | |
| commit | 3d18761f620a294ea6c5bff13c5994b93b29f3ed (patch) | |
| tree | 092fa6f8128bc187512be532801670417f215986 /gallery_dl/exception.py | |
| parent | a6e995c093de8aae2e91a0787281bb34c0b871eb (diff) | |
New upstream version 1.30.3.upstream/1.30.3
Diffstat (limited to 'gallery_dl/exception.py')
| -rw-r--r-- | gallery_dl/exception.py | 31 |
1 files changed, 26 insertions, 5 deletions
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""" |
