diff --git a/AO3/series.py b/AO3/series.py index a448ecf..26bb004 100644 --- a/AO3/series.py +++ b/AO3/series.py @@ -368,6 +368,8 @@ def get(self, *args, **kwargs): req = requester.request("get", *args, **kwargs, session=self._session.session) if req.status_code == 429: raise utils.HTTPError("We are being rate-limited. Try again in a while or reduce the number of requests") + if req.history and req.url.find("/users/login?restricted=true") != -1: + raise utils.PrivateWorkError(f"Error 302: Redirected to [{req.url}]") return req def request(self, url): diff --git a/AO3/utils.py b/AO3/utils.py index fc2a1e1..cb2e8ad 100644 --- a/AO3/utils.py +++ b/AO3/utils.py @@ -68,6 +68,11 @@ def __init__(self, message, errors=[]): super().__init__(message) self.errors = errors +class PrivateWorkError(Exception): + def __init__(self, message, errors=[]): + super().__init__(message) + self.errors = errors + class Query: def __init__(self): self.fields = [] diff --git a/AO3/works.py b/AO3/works.py index a2ea404..83c650f 100644 --- a/AO3/works.py +++ b/AO3/works.py @@ -923,6 +923,8 @@ def get(self, *args, **kwargs): req = requester.request("get", *args, **kwargs, session=self._session.session) if req.status_code == 429: raise utils.HTTPError("We are being rate-limited. Try again in a while or reduce the number of requests") + if req.history and req.url.find("/users/login?restricted=true") != -1: + raise utils.PrivateWorkError(f"Error 302: Redirected to [{req.url}]") return req def request(self, url):