Skip to content

Commit

Permalink
Add a CaptchaException()
Browse files Browse the repository at this point in the history
  • Loading branch information
BelKed committed Apr 20, 2024
1 parent 1f35aed commit ecc1767
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions edupage_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ class SecondFactorFailedException(Exception):

class InsufficientPermissionsException(Exception):
pass


class CaptchaException(Exception):
pass
5 changes: 4 additions & 1 deletion edupage_api/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from requests import Response

from edupage_api.exceptions import (BadCredentialsException,
from edupage_api.exceptions import (BadCredentialsException, CaptchaException,
MissingDataException, RequestError,
SecondFactorFailedException)
from edupage_api.module import EdupageModule, Module
Expand Down Expand Up @@ -175,6 +175,9 @@ def login(

response = self.edupage.session.post(request_url, parameters)

if "cap=1" in response.url or "lerr=b43b43" in response.url:
raise CaptchaException()

if "bad=1" in response.url:
raise BadCredentialsException()

Expand Down

0 comments on commit ecc1767

Please sign in to comment.