diff --git a/gallery_dl/exception.py b/gallery_dl/exception.py index 0bd52aac..6adda0d6 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) diff --git a/gallery_dl/extractor/civitai.py b/gallery_dl/extractor/civitai.py index dc5b7775..52b952e8 100644 --- a/gallery_dl/extractor/civitai.py +++ b/gallery_dl/extractor/civitai.py @@ -200,7 +200,7 @@ class CivitaiExtractor(Extractor): if "Authorization" not in self.api.headers and \ not self.cookies.get( "__Secure-civitai-token", domain=".civitai.com"): - raise exception.AuthRequired(("'api-key'", "cookies")) + raise exception.AuthRequired(("api-key", "authenticated cookies")) def _parse_query(self, value): return text.parse_query_list( diff --git a/gallery_dl/extractor/facebook.py b/gallery_dl/extractor/facebook.py index e5378c55..173321d5 100644 --- a/gallery_dl/extractor/facebook.py +++ b/gallery_dl/extractor/facebook.py @@ -318,7 +318,9 @@ class FacebookExtractor(Extractor): if ('"props":{"title":"This content isn\'t available right now"' in profile_photos_page): - raise exception.AuthRequired("cookies") + raise exception.AuthRequired( + "authenticated cookies", "profile", + "This content isn't available right now") set_id = self._extract_profile_set_id(profile_photos_page) avatar_page_url = text.extr( diff --git a/gallery_dl/extractor/iwara.py b/gallery_dl/extractor/iwara.py index 934b301d..179909bc 100644 --- a/gallery_dl/extractor/iwara.py +++ b/gallery_dl/extractor/iwara.py @@ -341,7 +341,8 @@ class IwaraAPI(): def favorites(self, type): if not self.username: - raise exception.AuthRequired("'username' & 'password'") + raise exception.AuthRequired( + "username & password", "your favorites") endpoint = f"/favorites/{type}s" return self._pagination(endpoint) diff --git a/gallery_dl/extractor/madokami.py b/gallery_dl/extractor/madokami.py index e87dbbaf..1db51263 100644 --- a/gallery_dl/extractor/madokami.py +++ b/gallery_dl/extractor/madokami.py @@ -31,7 +31,7 @@ class MadokamiMangaExtractor(MadokamiExtractor): def items(self): username, password = self._get_auth_info() if not username: - raise exception.AuthRequired("'username' & 'password'") + raise exception.AuthRequired("username & password") self.session.auth = util.HTTPBasicAuth(username, password) url = f"{self.root}/Manga/{self.groups[0]}"