Skip to content

Commit

Permalink
- fixed proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAlsFake committed Jan 2, 2025
1 parent a389fd6 commit 768acd0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "phub"
version = "4.7.5"
version = "4.7.6"
description = "An API for Pornhub"
authors = [
{name = 'Egsagon', email = "[email protected]"},
Expand Down
5 changes: 5 additions & 0 deletions src/phub/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@

RSS = 'https://www.pornhub.com/video/webmasterss'

PROXY = None
# Example Proxy dictionary:
# {"http://": "http://4.20.69.42:1337"}


MAX_CALL_RETRIES = 4 # Maximum times a HTTPError can be reproduced
MAX_CALL_TIMEOUT = .4 # Time to wait before retrying basic calls
CALL_TIMEOUT = 30 # Time to wait before retrying calls (in case no error happens)
Expand Down
11 changes: 4 additions & 7 deletions src/phub/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(self,
*,
language: literals.language = 'en',
delay: Union[int, float] = 0,
proxies: dict = None,
login: bool = True,
bypass_geo_blocking: bool = False,
change_title_language: bool = True,
Expand All @@ -49,13 +48,12 @@ def __init__(self,
password (str): Account password.
language (str): Client language (fr, en, ru, etc.)
delay (int | float): Minimum delay between requests.
proxies (dict): Dictionary of proxies for the requests.
login (bool): Whether to directly log in after initialization.
bypass_geo_blocking (bool): Whether to bypass geo-blocking.
change_title_language (bool): Whether to change title language into your language based on the input URL
use_webmaster_api (bool): Whether to use the webmaster API or HTML content extraction
Raises:
LoginFailed: If Pornhub refuses the authentification.
LoginFailed: If Pornhub refuses the authentication.
The reason will be passed as the error body.
'''

Expand All @@ -70,7 +68,6 @@ def __init__(self,
self.reset()

self.session.headers.update({"Accept-Language": language})
self.proxies = proxies
self.credentials = {'email': email,
'password': password}

Expand Down Expand Up @@ -98,9 +95,9 @@ def reset(self) -> None:
self.session = httpx.Client(
headers = consts.HEADERS,
cookies = consts.COOKIES,
follow_redirects = True
)
follow_redirects = True,
proxies = consts.PROXY)

self._clear_granted_token()

if self.bypass_geo_blocking:
Expand Down

0 comments on commit 768acd0

Please sign in to comment.