[exception] rename 'LoginRequired' to 'AuthRequired'
This commit is contained in:
@@ -16,7 +16,7 @@ Exception
|
||||
│ ├── HttpError
|
||||
│ │ └── ChallengeError
|
||||
│ ├── AuthorizationError
|
||||
│ │ └── LoginRequired
|
||||
│ │ └── AuthRequired
|
||||
│ ├── AuthenticationError
|
||||
│ └── NotFoundError
|
||||
├── InputError
|
||||
@@ -93,12 +93,20 @@ class AuthenticationError(ExtractionError):
|
||||
|
||||
class AuthorizationError(ExtractionError):
|
||||
"""Insufficient privileges to access a resource"""
|
||||
default = "Insufficient privileges to access the specified resource"
|
||||
default = "Insufficient privileges to access this resource"
|
||||
code = 16
|
||||
|
||||
|
||||
class LoginRequired(AuthorizationError):
|
||||
default = "Account credentials or cookies required"
|
||||
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"
|
||||
else:
|
||||
message = f"{' or '.join(required)} required"
|
||||
AuthorizationError.__init__(self, message)
|
||||
|
||||
|
||||
class NotFoundError(ExtractionError):
|
||||
|
||||
@@ -206,7 +206,7 @@ class CivitaiExtractor(Extractor):
|
||||
if "Authorization" not in self.api.headers and \
|
||||
not self.cookies.get(
|
||||
"__Secure-civitai-token", domain=".civitai.com"):
|
||||
raise exception.LoginRequired("'api-key' or cookies needed")
|
||||
raise exception.AuthRequired(("'api-key'", "cookies"))
|
||||
|
||||
def _parse_query(self, value):
|
||||
return text.parse_query_list(
|
||||
|
||||
@@ -216,9 +216,9 @@ class FacebookExtractor(Extractor):
|
||||
res = self.request(url, **kwargs)
|
||||
|
||||
if res.url.startswith(self.root + "/login"):
|
||||
raise exception.LoginRequires(
|
||||
f"You must be logged in to continue viewing images."
|
||||
f"{LEFT_OFF_TXT}"
|
||||
raise exception.AuthRequired(
|
||||
message=(f"You must be logged in to continue viewing images."
|
||||
f"{LEFT_OFF_TXT}")
|
||||
)
|
||||
|
||||
if b'{"__dr":"CometErrorRoot.react"}' in res.content:
|
||||
|
||||
@@ -341,7 +341,7 @@ class IwaraAPI():
|
||||
|
||||
def favorites(self, type):
|
||||
if not self.username:
|
||||
raise exception.LoginRequired("'username' and 'password' needed")
|
||||
raise exception.AuthRequired("'username' & 'password'")
|
||||
endpoint = f"/favorites/{type}s"
|
||||
return self._pagination(endpoint)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class MadokamiMangaExtractor(MadokamiExtractor):
|
||||
def items(self):
|
||||
username, password = self._get_auth_info()
|
||||
if not username:
|
||||
raise exception.LoginRequired("Missing 'username' & 'password'")
|
||||
raise exception.AuthRequired("'username' & 'password'")
|
||||
self.session.auth = util.HTTPBasicAuth(username, password)
|
||||
|
||||
url = f"{self.root}/Manga/{self.groups[0]}"
|
||||
|
||||
@@ -63,7 +63,7 @@ __tests__ = (
|
||||
"#comment" : "no username & password",
|
||||
"#class" : madokami.MadokamiMangaExtractor,
|
||||
"#auth" : False,
|
||||
"#exception": exception.LoginRequired,
|
||||
"#exception": exception.AuthRequired,
|
||||
},
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user