Skip to content
Closed
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
5 changes: 5 additions & 0 deletions rule34Py/rule34.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class rule34Py:
captcha_clearance: Union[str, None] = os.environ.get("R34_CAPTCHA_CLEARANCE", None)
#: The ``requests.Session`` object used when the client makes HTML requests.
session: requests.Session = None
#: The ``timeout`` option passed to session.get
timeout: None | (int | float) | tuple[(int | float), (int | float)] = 2.5 * 60
#: The ``User-Agent`` HTML header value used when the client makes HTML requests.
#: Defaults to either the value of the ``R34_USER_AGENT`` environment variable; or the ``rule34Py.rule34.DEFAULT_USER_AGENT``, if not asserted.
#: Can be overridden by the user at runtime to change User-Agents.
Expand Down Expand Up @@ -156,6 +158,9 @@ def _get(self, *args, **kwargs) -> requests.Response:
if self.captcha_clearance is not None:
kwargs["cookies"]["cf_clearance"] = self.captcha_clearance

# timeout
kwargs["timeout"] = self.timeout

return self.session.get(*args, **kwargs)

def get_comments(self, post_id: int) -> list[PostComment]:
Expand Down
Loading