phub 4.8.0__py3-none-any.whl → 4.8.2__py3-none-any.whl

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.
phub/objects/video.py CHANGED
@@ -18,7 +18,6 @@ from ..modules import parser, display
18
18
 
19
19
  if TYPE_CHECKING:
20
20
  from ..core import Client
21
- from ..utils import Quality
22
21
 
23
22
 
24
23
  class Video:
@@ -219,14 +218,22 @@ class Video:
219
218
  except Exception as e:
220
219
  self.logger.warning(f"Skipping invalid quality entry: {q}, {e}")
221
220
  continue
222
-
223
221
  return quality_urls
224
222
 
223
+ def get_segments(self, quality) -> list:
224
+ """
225
+ :param quality: (str) The video quality
226
+ :return: (list) A list of segments (URLs)
227
+ """
228
+ segments = self.client.core.get_segments(m3u8_url_master=self.m3u8_base_url, quality=quality)
229
+ return segments
225
230
 
226
231
  def download(self,
227
232
  path: Union[str, os.PathLike],
228
233
  downloader: Union[Callable, str] = "threaded",
229
- quality: Quality | str = 'best',
234
+ quality: str = 'best',
235
+ remux: bool = False,
236
+ display_remux: Callable[[int, int], None] = None,
230
237
  *,
231
238
  display: Callable[[int, int], None] = display.default()) -> str:
232
239
  '''
@@ -237,6 +244,8 @@ class Video:
237
244
  quality (Quality | str | int): The video quality.
238
245
  downloader (Callable): The download backend.
239
246
  display (Callable): The progress display.
247
+ remux (bool): Whether to remux the video from MPEG-TS to MP4 (h264)
248
+ display_remux (Callable[[int, int], None], optional): The display backend for remuxing.
240
249
 
241
250
  Returns:
242
251
  str: The downloader video path.
@@ -249,37 +258,14 @@ class Video:
249
258
  self.logger.info('Starting download for %s at %s', self, path)
250
259
 
251
260
  try:
252
- self.client.core.download(video=self, quality=quality, path=path, callback=display, downloader=downloader)
261
+ self.client.core.download(video=self, quality=quality, path=path, callback=display, downloader=downloader,
262
+ remux=remux, callback_remux=display_remux)
253
263
 
254
264
  except Exception as e:
255
265
  self.logger.error(f"An error occured while downloading video {e}")
256
266
 
257
267
  return path
258
268
 
259
- def get_direct_url(self, quality: Quality) -> str:
260
- '''
261
- Get the direct video URL given a specific quality.
262
-
263
- Args:
264
- quality (Quality): The video quality.
265
-
266
- Returns:
267
- str: The direct url.
268
- '''
269
-
270
- from ..utils import Quality
271
- qual = Quality(quality)
272
-
273
- # Get remote
274
- sources = self.fetch('page@mediaDefinitions')
275
- remote = [s for s in sources if 'remote' in s][0]['videoUrl']
276
-
277
- # Parse quality
278
- quals = {int(s['quality']): s['videoUrl']
279
- for s in self.client.call(remote).json()}
280
-
281
- return qual.select(quals)
282
-
283
269
  # === Interaction methods === #
284
270
 
285
271
  def _assert_internal_success(self, res: dict) -> None:
phub/tests/test_video.py CHANGED
@@ -23,7 +23,8 @@ def test_video_information():
23
23
  embed = video.embed
24
24
  image = video.image.url
25
25
  id = video.id
26
-
26
+ assert isinstance(video.download(path="./", quality="worst", remux=True), str)
27
+ assert isinstance(video.download(path="./", quality="worst"), str)
27
28
  assert isinstance(title, str) and len(title) > 3
28
29
  assert isinstance(likes, int) and len(str(likes)) >= 1
29
30
  assert isinstance(dislikes, int) and len(str(dislikes)) >= 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phub
3
- Version: 4.8.0
3
+ Version: 4.8.2
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
@@ -688,7 +688,6 @@ Requires-Python: >=3.9
688
688
  Description-Content-Type: text/markdown
689
689
  License-File: LICENSE
690
690
  Requires-Dist: httpx[brotli,socks]
691
- Requires-Dist: ffmpeg-progress-yield
692
691
  Requires-Dist: eaf_base_api
693
692
  Dynamic: license-file
694
693
 
@@ -17,16 +17,16 @@ phub/objects/image.py,sha256=qCLuaOy-EYzA_uXxiPRQeCLHPf9gFr0o7TDszQvWXZs,3376
17
17
  phub/objects/playlist.py,sha256=hpP76yH23LdDS0iL28jhp_iG7EGetYJA3xoqZZdXjTs,3278
18
18
  phub/objects/query.py,sha256=crYC-MJGEf04XO3hfU7FPyyHEnBWS9D8XbeQmtTnpzQ,11596
19
19
  phub/objects/user.py,sha256=pIumIGC_MQXQ-hjzf_0c0I_egL4WziHrh2e8XegArEc,8161
20
- phub/objects/video.py,sha256=oPfKaxCulvSWoCNvp0w7DZACfl9Vx8DaOdDWEye69w4,19191
20
+ phub/objects/video.py,sha256=NgsfxgqwjkiTKcNLEgwfMLfeGU7n2j4ZF3Vkq4LocR0,19168
21
21
  phub/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  phub/tests/test_auth.py,sha256=ySy1Aw0bogMGDSTmzVXO_W352cbRFzXUGjuDX1Iu0xE,609
23
23
  phub/tests/test_model.py,sha256=hRpmIjsx2z0EjTWsIpwT_vpHm-H4wCmZtvGWOohaIKQ,1426
24
24
  phub/tests/test_playlist.py,sha256=-hS5bIBecsv3zSNlUo66b73DdVbkYlmVThYip9Ivpss,1081
25
25
  phub/tests/test_search.py,sha256=VeqyjVzu0QnIYR6NhcujXy8wfCcWn1BlvKS06iY-7JY,1301
26
- phub/tests/test_video.py,sha256=bX-gPhDa34p6-5Ei20gh9opNkLs_08JHEfhVlQUwfMU,1312
27
- phub-4.8.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
28
- phub-4.8.0.dist-info/METADATA,sha256=hWshEqar7OxI6ZaGjINSVfkUratn5fGayKqtbctNNsc,41777
29
- phub-4.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- phub-4.8.0.dist-info/entry_points.txt,sha256=oxL1BvDV19M1IGLgwFElgb37PlmGnblDBEfMwx3x6u8,44
31
- phub-4.8.0.dist-info/top_level.txt,sha256=xqJ5Lg28Ba-pgvXf8qwpTFurW3neZhguNd8bhbQonZo,5
32
- phub-4.8.0.dist-info/RECORD,,
26
+ phub/tests/test_video.py,sha256=4E70tiza45byMFIrjBdnpP3xOSyk1YKoTGNP4_QTI0E,1465
27
+ phub-4.8.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
28
+ phub-4.8.2.dist-info/METADATA,sha256=A7_wFWtOTpS6k9qVA3VwX6A4ky-uuM24sef4gpExgu0,41740
29
+ phub-4.8.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ phub-4.8.2.dist-info/entry_points.txt,sha256=oxL1BvDV19M1IGLgwFElgb37PlmGnblDBEfMwx3x6u8,44
31
+ phub-4.8.2.dist-info/top_level.txt,sha256=xqJ5Lg28Ba-pgvXf8qwpTFurW3neZhguNd8bhbQonZo,5
32
+ phub-4.8.2.dist-info/RECORD,,
File without changes