Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions python_anticaptcha/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def report_incorrect_image(self) -> bool:
def report_incorrect_recaptcha(self) -> bool:
return self.client.reportIncorrectRecaptcha(self.task_id)

def __repr__(self) -> str:
status = self._last_result.get("status") if self._last_result else None
if status:
return f"<Job task_id={self.task_id} status={status!r}>"
return f"<Job task_id={self.task_id}>"

def join(self, maximum_time: int | None = None) -> None:
elapsed_time = 0
maximum_time = maximum_time or MAXIMUM_JOIN_TIME
Expand Down Expand Up @@ -115,6 +121,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def close(self):
self.session.close()

def __repr__(self) -> str:
from urllib.parse import urlparse
host = urlparse(self.base_url).hostname or self.base_url
return f"<AnticaptchaClient host={host!r}>"

@property
def client_ip(self) -> str:
if not hasattr(self, "_client_ip"):
Expand Down
6 changes: 6 additions & 0 deletions python_anticaptcha/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def serialize(self, **result: Any) -> dict[str, Any]:
result["type"] = self.type
return result

def __repr__(self) -> str:
attrs = {k: v for k, v in self.__dict__.items()
if not k.startswith("_") and v is not None}
fields = " ".join(f"{k}={v!r}" for k, v in attrs.items())
return f"<{self.__class__.__name__} {fields}>"


class UserAgentMixin(BaseTask):
def __init__(self, *args: Any, **kwargs: Any) -> None:
Expand Down
Loading