diff --git a/faapi/exceptions.py b/faapi/exceptions.py index 63326cc..14247b6 100644 --- a/faapi/exceptions.py +++ b/faapi/exceptions.py @@ -52,5 +52,11 @@ class NoticeMessage(ParsingError): """ +class ClassicTheme(ParsingError): + """ + The cookies supplied are for an account using the Classic theme. Please change your theme to Modern to use FAAPI. + """ + + def _raise_exception(err: BaseException): raise err diff --git a/faapi/parse.py b/faapi/parse.py index 066d4d3..5bdeb2f 100644 --- a/faapi/parse.py +++ b/faapi/parse.py @@ -27,6 +27,7 @@ from .exceptions import NoTitle from .exceptions import ParsingError from .exceptions import ServerError +from .exceptions import ClassicTheme relative_url: Pattern = re_compile(r"^(?:https?://(?:www\.)?furaffinity\.net)?(.*)") mentions_regexp: Pattern = re_compile(r"^(?:(?:https?://)?(?:www\.)?furaffinity\.net)?/user/([^/#]+).*$") @@ -51,6 +52,8 @@ def parse_page(text: str) -> BeautifulSoup: def check_page_raise(page: BeautifulSoup) -> None: if page is None: raise NonePage + elif page.body and "classic" in page.body.attrs.get("data-static-path", ""): + raise ClassicTheme elif not (title := page.title.text.lower() if page.title else ""): raise NoTitle elif title.startswith("account disabled"):