Skip to content

Commit d5df976

Browse files
committed
Downgrade python 3.11 >> 3.9
1 parent 64d5b59 commit d5df976

File tree

17 files changed

+83
-117
lines changed

17 files changed

+83
-117
lines changed

README.md

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img width="300" src="https://github.com/Egsagon/PHUB/blob/master/assets/logo.svg">
2+
<img width="200" src="https://github.com/Egsagon/PHUB/blob/master/assets/logo.svg">
33
</p>
44

55
<div align="center">
@@ -9,18 +9,15 @@
99
</div>
1010

1111
<br>
12-
<br>
13-
PHUB is a hybrid API for Pornhub. It is able to communicate with Pornhub
14-
using both web-scraping and Pornhub's HubTraffic API. It is
15-
able to access most used or useful PH features, such as video searching,
16-
accessing account features, video downloading, and a lot more.
12+
PHUB is an easy-to-use API wrapper for Pornhub. It can access most used or useful
13+
PH features, such as video searching, account features, video downloading, and more.
1714

1815
> [!WARNING]
1916
> This project is probably against Pornhub TOS. Use at your own risks.
2017
21-
## Installation
18+
# Installation
2219

23-
- Install using `pip` (python `3.11` or higher required, recommended version):
20+
- Install using `pip` (python `3.9` or higher required):
2421
```shell
2522
pip install --upgrade phub
2623
```
@@ -30,26 +27,15 @@ pip install --upgrade phub
3027
pip install --upgrade git+https://github.com/EchterAlsFake/PHUB.git
3128
```
3229

33-
- Or, for python 3.10 and higher.
34-
```shell
35-
pip install --upgrade git+https://github.com/EchterAlsFake/PHUB.git@py-3.10
36-
```
37-
38-
- Or, for even lower python versions, there is automatic branch with several features removed (might be unstable).
39-
```shell
40-
pip install --upgrade git+https://github.com/EchterAlsFake/PHUB.git@compat
41-
```
42-
43-
## Usage from command line
30+
# Usage from command line
4431
```shell
4532
# Download a single video
4633
py -m phub https://www.pornhub.com/view_video.php?viewkey=abcdef
4734
# Download multiple videos from a text file
4835
py -m phub path/to/file.txt --quality best --downloader threaded --output video.mp4
4936
```
50-
###### Note: It does not matter how the URLs in the files are aranged, preferably one per line.
5137

52-
## Quickstart
38+
# Quickstart
5339

5440
> [!NOTE]
5541
> You can find the docs on this project [here](https://phub.readthedocs.io).
@@ -83,17 +69,15 @@ client.account.liked
8369
client.account.recommended
8470
```
8571

86-
# Note
87-
<strong>This repository was initiated and maintained by [Egsagon](https://github.com/Egsagon)
88-
He doesn't have any time to maintain this and transferred me the ownership.
89-
I'll do my best to maintain this repository functional.</strong>
90-
91-
92-
## License
72+
# License
9373

9474
PHUB uses GPLv3. See the `LICENSE` file.
9575

96-
## Contributing
76+
This repository was initiated and maintained by [Egsagon](https://github.com/Egsagon)
77+
He doesn't have any time to maintain this and transferred me the ownership.
78+
I'll do my best to maintain this repository functional.
79+
80+
# Contributing
9781

9882
Feel free to contribute to this project by submitting
9983
feature requests, issues, bugs, or whatever.

pypi.md

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
<p align="center">
2-
<img width="300" src="https://raw.githubusercontent.com/Egsagon/PHUB/master/assets/logo.svg">
2+
<img width="200" src="https://raw.githubusercontent.com/Egsagon/PHUB/master/assets/logo.svg">
33
</p>
44

55
# PHUB - An API wrapper for PornHub.
66

7-
PHUB is a hybrid API for Pornhub. It is able to communicate with Pornhub
8-
using both web-scraping and Pornhub's HubTraffic API. It is
9-
able to access most used or useful PH features, such as video searching,
10-
accessing account features, video downloading, and a lot more.
7+
PHUB is an easy-to-use API wrapper for Pornhub. It can access most used or useful
8+
PH features, such as video searching, account features, video downloading, and more.
119

12-
Learn more on the project [documentation](https://phub.readthedocs.io) and
13-
[GitHub page](https://github.com/EchterAlsFake/PHUB).
14-
15-
## Installation
16-
17-
```sh
18-
pip install --upgrade phub
19-
```
20-
21-
## Quickstart
22-
23-
```python
24-
import phub
25-
26-
client = phub.Client()
27-
28-
video = client.get(url = '...')
29-
video.download('my-video.mp4', quality = 'best')
30-
```
10+
- Project documentation: [phub.readthedocs.io](https://phub.readthedocs.io)
11+
- Project repository: [EchterAlsFake/PHUB](https://github.com/EchterAlsFake/PHUB)

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[project]
22
name = "phub"
3-
version = "4.6"
3+
version = "4.7"
44
description = "An API for Pornhub"
55
authors = [
6-
{name = 'Egsagon', email = "egsagon12@gmail.com"},
6+
{name = 'Egsagon', email = "egsagon.git@gmail.com"},
77
{name = "EchterAlsFake", email = "EchterAlsFake@proton.me"}
88
]
99
license = {file = "LICENSE"}
@@ -14,7 +14,7 @@ classifiers = [
1414
"Programming Language :: Python"
1515
]
1616
dependencies = ["requests", "ffmpeg-progress-yield"]
17-
requires-python = ">=3.11"
17+
requires-python = ">=3.9"
1818

1919
[project.optional-dependencies]
2020
cli = ["click"]

src/phub/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
## PHUB v4.5.3
2+
## PHUB v4.7
33
44
See https://phub.readthedocs.io/en/latest/ for docs.
55
See https://github.com/EchterAlsFake/PHUB for code.
@@ -9,7 +9,7 @@
99
__author__ = 'Egsagon, EchterAlsFake'
1010
__copyright__ = 'Copyright 2024, PHUB'
1111
__license__ = 'GPLv3'
12-
__version__ = '4.5.3'
12+
__version__ = '4.7'
1313

1414
__all__ = ['Client', 'Quality', 'core', 'utils',
1515
'consts', 'errors', 'objects', 'modules']

src/phub/consts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
import re as engine
77
from re import Pattern as p
8-
from typing import Callable
8+
from typing import Callable, Union
99

1010
from . import errors
1111

@@ -63,7 +63,7 @@
6363

6464
# Regex wrappers
6565

66-
WrappedRegex = Callable[[str, bool | None], str | list[str]]
66+
WrappedRegex = Callable[[str, Union[bool, None]], Union[str, list[str]]]
6767

6868
def _throw_re_error(pattern: str) -> None:
6969
'''

src/phub/core.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77

88
import requests
9-
from typing import Iterable
9+
from typing import Iterable, Union
1010
from functools import cached_property
1111

1212
from . import utils
@@ -32,7 +32,7 @@ def __init__(self,
3232
password: str = None,
3333
*,
3434
language: literals.language = 'en,en-US',
35-
delay: int | float = 0,
35+
delay: Union[int, float] = 0,
3636
proxies: dict = None,
3737
login: bool = True) -> None:
3838
'''
@@ -143,7 +143,8 @@ def call(self,
143143
raise ConnectionError('Pornhub raised error 429: too many requests')
144144

145145
# Attempt to resolve the challenge if needed
146-
if challenge := consts.re.get_challenge(response.text, False):
146+
challenge = consts.re.get_challenge(response.text, False)
147+
if challenge:
147148
logger.info('Challenge found, attempting to resolve')
148149
parser.challenge(self, *challenge)
149150

@@ -214,7 +215,7 @@ def login(self,
214215
self.logged = bool(success)
215216
return self.logged
216217

217-
def get(self, video: str | Video) -> Video:
218+
def get(self, video: Union[str, Video]) -> Video:
218219
'''
219220
Get a Pornhub video.
220221
@@ -249,7 +250,7 @@ def get(self, video: str | Video) -> Video:
249250

250251
return Video(self, url)
251252

252-
def get_user(self, user: str | User) -> User:
253+
def get_user(self, user: Union[str, User]) -> User:
253254
'''
254255
Get a Pornhub user.
255256
@@ -270,7 +271,7 @@ def search_hubtraffic(self,
270271
query: str,
271272
*,
272273
category: literals.category = None,
273-
tags: str | list[str] = None,
274+
tags: Union[str, list[str]] = None,
274275
sort: literals.ht_sort = None,
275276
period: literals.ht_period = None) -> Query:
276277
'''
@@ -312,7 +313,7 @@ def search(self,
312313
*,
313314
production: literals.production = None,
314315
category: literals.category = None,
315-
exclude_category: literals.category | Iterable[literals.category] = None,
316+
exclude_category: Union[literals.category, Iterable[literals.category]] = None,
316317
hd: bool = None,
317318
sort: literals.sort = None,
318319
period: literals.period = None) -> Query:
@@ -361,7 +362,7 @@ def search(self,
361362
query_repr = query
362363
)
363364

364-
def get_playlist(self, playlist: str | int | Playlist) -> Playlist:
365+
def get_playlist(self, playlist: Union[str, int, Playlist]) -> Playlist:
365366
'''
366367
Get a Pornhub playlist.
367368
@@ -375,7 +376,7 @@ def get_playlist(self, playlist: str | int | Playlist) -> Playlist:
375376
TypeError: If the playlist argument is invalid.
376377
'''
377378

378-
if not isinstance(playlist, str | int | Playlist):
379+
if not isinstance(playlist, (str, int, Playlist)):
379380
raise TypeError(f'Invalid type: {type(playlist)} should be str, int or Playlist.')
380381

381382
if isinstance(playlist, Playlist):

src/phub/literals.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
PHUB Literals.
33
'''
44

5-
from typing import Literal, Iterable, Type
5+
from typing import Literal, Iterable, Type, Union
66

77
# Language locales
88
language = Literal['en', 'cn', 'de', 'fr', 'it', 'pt', 'pl', 'rt', 'nl', 'cz', 'jp']
@@ -199,7 +199,7 @@ def _craft_list(args: Iterable[str]) -> str:
199199
if args:
200200
return '-'.join(list(args))
201201

202-
def _craft_boolean(b: bool | None) -> int | None:
202+
def _craft_boolean(b: Union[bool, None]) -> Union[int, None]:
203203
'''
204204
Craft a boolean into a url-valid int.
205205
@@ -213,7 +213,7 @@ def _craft_boolean(b: bool | None) -> int | None:
213213
if b is not None:
214214
return int(bool(b))
215215

216-
def ass(name: str, item: str | list[str], literal: Type) -> None:
216+
def ass(name: str, item: Union[str, list[str]], literal: Type) -> None:
217217
'''
218218
Assert one or multiple items are part of a literal.
219219

src/phub/modules/display.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import os
22
import sys
33
import time
4-
from typing import Callable
4+
from typing import Callable, Union
55

6-
def progress(color: dict | None = dict(c1=30, c2=33, c3=34, c4=36), desc: str = 'Downloading') -> Callable:
6+
def progress(color: Union[dict, None] = dict(c1=30, c2=33, c3=34, c4=36), desc: str = 'Downloading') -> Callable:
77
'''
88
Simple progress display, with segment, percentage and speed display.
99

src/phub/modules/download.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import logging
55
import requests.adapters
66
from pathlib import Path
7-
from typing import TYPE_CHECKING, Callable
8-
from concurrent.futures import ThreadPoolExecutor as Pool, as_completed
97
from ffmpeg_progress_yield import FfmpegProgress
8+
from typing import TYPE_CHECKING, Callable, Union
9+
from concurrent.futures import ThreadPoolExecutor as Pool, as_completed
10+
1011
from .. import consts
1112

1213
if TYPE_CHECKING:
@@ -19,7 +20,6 @@
1920
CallbackType = Callable[[int, int], None]
2021

2122

22-
2323
def default(video: Video,
2424
quality: Quality,
2525
callback: CallbackType,
@@ -72,7 +72,7 @@ def default(video: Video,
7272

7373
logger.info('Downloading successful.')
7474

75-
def FFMPEG(video: Video, quality: Quality, callback: CallbackType, path: str | Path, start: int = 0) -> None:
75+
def FFMPEG(video: Video, quality: Quality, callback: CallbackType, path: Union[str, Path], start: int = 0) -> None:
7676
'''
7777
Download using FFMPEG with real-time progress reporting.
7878
FFMPEG must be installed on your system.
@@ -115,7 +115,6 @@ def FFMPEG(video: Video, quality: Quality, callback: CallbackType, path: str | P
115115
except Exception as err:
116116
logger.error('Error while downloading: %s', err)
117117

118-
119118
def _thread(client: Client, url: str, timeout: int) -> bytes:
120119
'''
121120
Download a single segment using the client's call method.
@@ -130,7 +129,6 @@ def _thread(client: Client, url: str, timeout: int) -> bytes:
130129
logging.warning(f"Failed to download segment {url}: {e}")
131130
return (url, b'', False)
132131

133-
134132
# Modify _base_threaded to use ThreadPoolExecutor
135133
def _base_threaded(client: Client, segments: list[str], callback: CallbackType, max_workers: int = 20,
136134
timeout: int = 10) -> dict[str, bytes]:
@@ -162,7 +160,6 @@ def _base_threaded(client: Client, segments: list[str], callback: CallbackType,
162160
client.session.mount('https://', old_adapter)
163161
return buffer
164162

165-
166163
def threaded(max_workers: int = 20,
167164
timeout: int = 10) -> Callable:
168165
'''

src/phub/objects/account.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44
from functools import cached_property
5-
from typing import TYPE_CHECKING, Self, Literal, Iterator
5+
from typing import TYPE_CHECKING, Literal, Iterator, Union
66

77
from .. import utils
88
from .. import consts
@@ -22,7 +22,7 @@ class Account:
2222
If the login fails, there will be None.
2323
'''
2424

25-
def __new__(cls, client: Client) -> Self | None:
25+
def __new__(cls, client: Client) -> Union[object, None]:
2626
'''
2727
Check if the object creation is needed.
2828
@@ -177,7 +177,7 @@ def feed(self) -> Feed:
177177
return Feed(self.client)
178178

179179
def dictify(self,
180-
keys: Literal['all'] | list[str] = 'all',
180+
keys: Union[Literal['all'], list[str]] = 'all',
181181
recursive: bool = False) -> dict:
182182
'''
183183
Convert the object to a dictionary.

0 commit comments

Comments
 (0)