phub 4.8.2__tar.gz → 4.8.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {phub-4.8.2 → phub-4.8.4}/PKG-INFO +2 -1
  2. {phub-4.8.2 → phub-4.8.4}/pyproject.toml +2 -2
  3. {phub-4.8.2 → phub-4.8.4}/src/phub/__main__.py +15 -7
  4. {phub-4.8.2 → phub-4.8.4}/src/phub/core.py +12 -11
  5. {phub-4.8.2 → phub-4.8.4}/src/phub/modules/display.py +1 -1
  6. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/video.py +1 -1
  7. {phub-4.8.2 → phub-4.8.4}/src/phub.egg-info/PKG-INFO +2 -1
  8. {phub-4.8.2 → phub-4.8.4}/src/phub.egg-info/requires.txt +1 -0
  9. {phub-4.8.2 → phub-4.8.4}/LICENSE +0 -0
  10. {phub-4.8.2 → phub-4.8.4}/README.md +0 -0
  11. {phub-4.8.2 → phub-4.8.4}/pypi.md +0 -0
  12. {phub-4.8.2 → phub-4.8.4}/setup.cfg +0 -0
  13. {phub-4.8.2 → phub-4.8.4}/setup.py +0 -0
  14. {phub-4.8.2 → phub-4.8.4}/src/phub/__init__.py +0 -0
  15. {phub-4.8.2 → phub-4.8.4}/src/phub/consts.py +0 -0
  16. {phub-4.8.2 → phub-4.8.4}/src/phub/errors.py +0 -0
  17. {phub-4.8.2 → phub-4.8.4}/src/phub/literals.py +0 -0
  18. {phub-4.8.2 → phub-4.8.4}/src/phub/modules/__init__.py +0 -0
  19. {phub-4.8.2 → phub-4.8.4}/src/phub/modules/parser.py +0 -0
  20. {phub-4.8.2 → phub-4.8.4}/src/phub/modules/rss.py +0 -0
  21. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/__init__.py +0 -0
  22. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/account.py +0 -0
  23. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/data.py +0 -0
  24. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/feed.py +0 -0
  25. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/image.py +0 -0
  26. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/playlist.py +0 -0
  27. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/query.py +0 -0
  28. {phub-4.8.2 → phub-4.8.4}/src/phub/objects/user.py +0 -0
  29. {phub-4.8.2 → phub-4.8.4}/src/phub/tests/__init__.py +0 -0
  30. {phub-4.8.2 → phub-4.8.4}/src/phub/tests/test_auth.py +0 -0
  31. {phub-4.8.2 → phub-4.8.4}/src/phub/tests/test_model.py +0 -0
  32. {phub-4.8.2 → phub-4.8.4}/src/phub/tests/test_playlist.py +0 -0
  33. {phub-4.8.2 → phub-4.8.4}/src/phub/tests/test_search.py +0 -0
  34. {phub-4.8.2 → phub-4.8.4}/src/phub/tests/test_video.py +0 -0
  35. {phub-4.8.2 → phub-4.8.4}/src/phub/utils.py +0 -0
  36. {phub-4.8.2 → phub-4.8.4}/src/phub.egg-info/SOURCES.txt +0 -0
  37. {phub-4.8.2 → phub-4.8.4}/src/phub.egg-info/dependency_links.txt +0 -0
  38. {phub-4.8.2 → phub-4.8.4}/src/phub.egg-info/entry_points.txt +0 -0
  39. {phub-4.8.2 → phub-4.8.4}/src/phub.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phub
3
- Version: 4.8.2
3
+ Version: 4.8.4
4
4
  Summary: An API for Pornhub
5
5
  Author-email: Egsagon <egsagon.git@gmail.com>, EchterAlsFake <EchterAlsFake@proton.me>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -689,6 +689,7 @@ Description-Content-Type: text/markdown
689
689
  License-File: LICENSE
690
690
  Requires-Dist: httpx[brotli,socks]
691
691
  Requires-Dist: eaf_base_api
692
+ Requires-Dist: h2
692
693
  Dynamic: license-file
693
694
 
694
695
  <p align="center">
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "phub"
3
- version = "4.8.2"
3
+ version = "4.8.4"
4
4
  description = "An API for Pornhub"
5
5
  authors = [
6
6
  {name = 'Egsagon', email = "egsagon.git@gmail.com"},
@@ -13,7 +13,7 @@ classifiers = [
13
13
  "Development Status :: 4 - Beta",
14
14
  "Programming Language :: Python"
15
15
  ]
16
- dependencies = ["httpx[brotli,socks]", "eaf_base_api"]
16
+ dependencies = ["httpx[brotli,socks]", "eaf_base_api", "h2"]
17
17
  requires-python = ">=3.9"
18
18
 
19
19
 
@@ -4,8 +4,9 @@ PHUB built-in CLI.
4
4
 
5
5
  import os
6
6
  import argparse
7
- import re
8
7
 
8
+ from typing import Union
9
+ from base_api import BaseCore
9
10
  from phub import Client, Video
10
11
 
11
12
 
@@ -22,7 +23,7 @@ def text_progress_bar(downloaded, total, title=False):
22
23
  print(f"\r | {title} | -->: [{bar}] {percents}%", end='')
23
24
 
24
25
 
25
- def download_video(client: Client, url: [str, Video], output: str, quality: str, downloader: str):
26
+ def download_video(client: Client, url: Union[str | Video], output: str, quality: str, downloader: str, use_video_id=False):
26
27
  if not isinstance(url, Video):
27
28
  video = client.get(url)
28
29
 
@@ -33,10 +34,15 @@ def download_video(client: Client, url: [str, Video], output: str, quality: str,
33
34
  else:
34
35
  raise "Some error happened here, please report on GitHub, thank you :) "
35
36
 
36
- title = re.sub(r'[<>:"/\\|?*]', '', video.title)
37
+ if use_video_id:
38
+ title = video.id
39
+
40
+ else:
41
+ title = BaseCore().strip_title(title=video.title)
42
+
37
43
  final_output_path = os.path.join(output, title + ".mp4")
38
44
 
39
- print(f"Downloading: {title} to: {final_output_path}")
45
+ print(f"Downloading: {video.title} to: {final_output_path}")
40
46
  video.download(path=final_output_path, quality=quality, downloader=downloader, display=text_progress_bar)
41
47
  print(f"Successfully downloaded: {title}")
42
48
 
@@ -47,6 +53,7 @@ def main():
47
53
  group.add_argument("-url", type=str, help="a PornHub Video URL", default="")
48
54
  group.add_argument("-model", type=str, help="a Pornhub Model URL", default="")
49
55
  parser.add_argument("-video_limit", type=int, help="the maximum number of videos to download from a model (Default: all)", default=100000)
56
+ parser.add_argument("--use-video-id", action="store_true", help="uses video ID as the title instead of the original video title")
50
57
  group.add_argument("-file", type=str, help="List to a file with Video URLs (separated by new lines)", default="")
51
58
  parser.add_argument("-downloader", type=str, help="The threading (download backend) to use", choices=[
52
59
  "threaded", "default", "ffmpeg"], default="threaded")
@@ -64,11 +71,12 @@ def main():
64
71
  model = args.model
65
72
  video_limit = args.video_limit
66
73
  file = args.file
74
+ use_video_id = args.use_video_id
67
75
 
68
76
  client = Client()
69
77
 
70
78
  if len(url) >= 3: # Comparison with not == "" doesn't work, don't ask me why I have no fucking idea...
71
- download_video(client=client, url=url, output=output, quality=quality, downloader=downloader)
79
+ download_video(client=client, url=url, output=output, quality=quality, downloader=downloader, use_video_id=use_video_id)
72
80
 
73
81
  elif len(model) >= 3:
74
82
  model_videos = client.get_user(model).videos
@@ -78,7 +86,7 @@ def main():
78
86
  if idx >= video_limit:
79
87
  break
80
88
 
81
- download_video(client=client, url=video, output=output, quality=quality, downloader=downloader)
89
+ download_video(client=client, url=video, output=output, quality=quality, downloader=downloader, use_video_id=use_video_id)
82
90
  idx += 1
83
91
 
84
92
  elif len(file) >= 1:
@@ -95,7 +103,7 @@ def main():
95
103
 
96
104
  for idx, url in enumerate(urls, start=1):
97
105
  print(f"[{idx}|{len(urls)}] Downloading: {url}")
98
- download_video(client=client, url=url, output=output, quality=quality, downloader=downloader)
106
+ download_video(client=client, url=url, output=output, quality=quality, downloader=downloader, use_video_id=use_video_id)
99
107
 
100
108
 
101
109
  if __name__ == '__main__':
@@ -7,9 +7,10 @@ import logging
7
7
  import random
8
8
  import httpx
9
9
 
10
- from typing import Iterable, Union
11
10
  from functools import cached_property
11
+ from typing import Iterable, Union, Optional
12
12
  from base_api.base import BaseCore, setup_logger
13
+ from base_api.modules.config import RuntimeConfig
13
14
 
14
15
  from . import utils
15
16
  from . import consts
@@ -39,7 +40,7 @@ class Client:
39
40
  bypass_geo_blocking: bool = False,
40
41
  change_title_language: bool = True,
41
42
  use_webmaster_api: bool = True,
42
- core=None) -> None:
43
+ core: Optional[BaseCore] = None) -> None:
43
44
  '''
44
45
  Initialises a new client.
45
46
 
@@ -57,9 +58,10 @@ class Client:
57
58
  '''
58
59
 
59
60
  self.logger = setup_logger(name="PHUB API - [Client]", log_file=None, level=logging.ERROR)
60
- self.core = core or BaseCore()
61
- self.core.config.cookies = consts.COOKIES
62
- self.core.config.headers = consts.HEADERS
61
+ self.core = core or BaseCore(config=RuntimeConfig())
62
+ self.core.initialize_session()
63
+ self.core.session.headers.update(consts.HEADERS)
64
+ self.core.session.cookies.update(consts.HEADERS)
63
65
  # Applying PornHub specific cookies and headers to base API
64
66
  self.logger.debug('Initialised new Client %s', self)
65
67
 
@@ -71,8 +73,7 @@ class Client:
71
73
 
72
74
  self.reset()
73
75
 
74
- self.core.config.headers.update({"Accept-Language": language})
75
- self.core.update_headers({"Accept-Language": language})
76
+ self.core.session.headers.update({"Accept-Language": language})
76
77
  self.credentials = {'email': email,
77
78
  'password': password}
78
79
 
@@ -102,11 +103,11 @@ class Client:
102
103
  language_code = "fr"
103
104
 
104
105
  # Faking the X-Forwarded-For header (Fake IP source)
105
- self.core.config.headers.update({"X-Forwarded-For": f"{ip}"})
106
+ self.core.session.headers.update({"X-Forwarded-For": f"{ip}"})
106
107
  # Setting the Accept-Language tag to French, because the faked IP comes from france
107
- self.core.config.headers.update({"Accept-Language": f"{language_code}"})
108
+ self.core.session.headers.update({"Accept-Language": f"{language_code}"})
108
109
  # Setting the country code also to french
109
- self.core.config.headers.update({"CF-IPCountry": f"{language_code}"})
110
+ self.core.session.headers.update({"CF-IPCountry": f"{language_code}"})
110
111
  logging.debug(f"Using faked headers for geo-bypass: {self.core.config.session.headers}")
111
112
 
112
113
  def call(self,
@@ -139,7 +140,7 @@ class Client:
139
140
  self.logger.log(logging.DEBUG if silent else logging.INFO, 'Fetching %s', func or '/')
140
141
 
141
142
  if headers:
142
- self.core.config.headers = headers
143
+ self.core.session.headers = headers
143
144
 
144
145
  if not self.language == "en":
145
146
  host = consts.LANGUAGE_MAPPING.get(self.language)
@@ -20,7 +20,7 @@ def progress(color: Union[dict, None] = dict(c1=30, c2=33, c3=34, c4=36), desc:
20
20
  color['c0'] = 0
21
21
  color = {k: '' if v == '' else f'\033[{v}m' for k, v in color.items()}
22
22
 
23
- tem = '\r{c1}' + desc + ' {c2}{percent}%{c0} - {c3}{cur}{c0}/{c3}{total}i{c0}' # ({c4}{speed}ips{c0})
23
+ tem = '\r{c1}' + desc + ' {c2}{percent}%{c0} - {c3}{cur}{c0}/{c3}{total}{c0}' # ({c4}{speed}ips{c0})
24
24
  done = False
25
25
  start = time.time()
26
26
 
@@ -262,7 +262,7 @@ class Video:
262
262
  remux=remux, callback_remux=display_remux)
263
263
 
264
264
  except Exception as e:
265
- self.logger.error(f"An error occured while downloading video {e}")
265
+ self.logger.error(f"An error occurred while downloading video {e}")
266
266
 
267
267
  return path
268
268
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phub
3
- Version: 4.8.2
3
+ Version: 4.8.4
4
4
  Summary: An API for Pornhub
5
5
  Author-email: Egsagon <egsagon.git@gmail.com>, EchterAlsFake <EchterAlsFake@proton.me>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -689,6 +689,7 @@ Description-Content-Type: text/markdown
689
689
  License-File: LICENSE
690
690
  Requires-Dist: httpx[brotli,socks]
691
691
  Requires-Dist: eaf_base_api
692
+ Requires-Dist: h2
692
693
  Dynamic: license-file
693
694
 
694
695
  <p align="center">
@@ -1,2 +1,3 @@
1
1
  httpx[brotli,socks]
2
2
  eaf_base_api
3
+ h2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes