phub 4.8.5__py3-none-any.whl → 4.8.7__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/consts.py CHANGED
@@ -227,7 +227,7 @@ class re:
227
227
  container = find( engine.DOTALL, r'class=\"container(.*)' ) # Get the page container
228
228
  document = find( engine.DOTALL, r'.*' ) # Match a whole document
229
229
  get_playlist_unavailable = find( engine.DOTALL, r': (\d+)</h5' ) # Get playlist unavailable videos amount
230
- get_playlist_size = find( engine.DOTALL, r'var itemsCount = (.*?) ||' ) # Get playlist video amount
230
+ get_playlist_size = find( engine.DOTALL, r'var itemsCount = (.*?) ||' ) # Get playlist video amount
231
231
  get_playlist_likes = find( engine.DOTALL, r'<span class="votesUp">(.*?)</span>' ) # Get playlist likes
232
232
  get_playlist_dislikes = find( engine.DOTALL, r'<span class="votesDown">(.*?)</span>' ) # Get playlist dislikes
233
233
  get_playlist_ratings = find( engine.DOTALL, r'<span class="percent">(.*?)%</span>' ) # Get paylist like/dislike ratio
phub/core.py CHANGED
@@ -5,6 +5,8 @@ import re
5
5
  import time
6
6
  import logging
7
7
  import random
8
+ import traceback
9
+
8
10
  import httpx
9
11
 
10
12
  from functools import cached_property
@@ -61,7 +63,7 @@ class Client:
61
63
  self.core = core or BaseCore(config=RuntimeConfig())
62
64
  self.core.initialize_session()
63
65
  self.core.session.headers.update(consts.HEADERS)
64
- self.core.session.cookies.update(consts.HEADERS)
66
+ self.core.session.cookies.update(consts.COOKIES)
65
67
  # Applying PornHub specific cookies and headers to base API
66
68
  self.logger.debug('Initialised new Client %s', self)
67
69
 
@@ -117,6 +119,7 @@ class Client:
117
119
  headers: dict = None,
118
120
  throw: bool = True,
119
121
  silent: bool = False,
122
+ params: dict = None,
120
123
  get_response = True) -> httpx.Response:
121
124
  '''
122
125
  Used internally to send a request or an API call.
@@ -156,6 +159,7 @@ class Client:
156
159
  method = method,
157
160
  url = url,
158
161
  data = data,
162
+ params = params,
159
163
  get_response=get_response)
160
164
 
161
165
  # Silent 429 errors
@@ -175,6 +179,7 @@ class Client:
175
179
  break
176
180
 
177
181
  except Exception as err:
182
+ print(traceback.format_exc())
178
183
  self.logger.log(logging.DEBUG if silent else logging.WARNING,
179
184
  f'Call failed: {repr(err)}. Retrying (attempt {i + 1}/{self.core.config.max_retries})')
180
185
  continue
phub/modules/parser.py CHANGED
@@ -80,6 +80,6 @@ def challenge(client: Client, challenge: str, token: str) -> None:
80
80
  # Build and inject cookie
81
81
  cookie = f'{n}*{p // n}:{s}:{token}:1'
82
82
  client.core.config.cookies = {'KEY': cookie}
83
- client.core.update_cookies()
83
+ client.core.session.cookies.update({'KEY': cookie})
84
84
  logger.info('Injected cookie %s', cookie)
85
85
  # EOF
phub/objects/video.py CHANGED
@@ -5,10 +5,14 @@ import os
5
5
  import random
6
6
  import logging
7
7
  from functools import cached_property
8
+
9
+ import httpx
8
10
  from base_api.base import setup_logger
9
11
  from datetime import datetime, timedelta
10
12
  from typing import TYPE_CHECKING, Iterator, Literal, Callable, Any, Union
11
13
 
14
+ from httpx import request
15
+
12
16
  from . import Tag, Like, User, Image
13
17
  from .. import utils
14
18
  from .. import errors
@@ -383,7 +387,7 @@ class Video:
383
387
 
384
388
  self._assert_internal_success(res.json())
385
389
 
386
- def watch_later(self, toggle: bool = True) -> None:
390
+ def watch_later(self, toggle: bool = True) -> bool:
387
391
  '''
388
392
  Add or remove the video to the watch later playlist.
389
393
 
@@ -391,14 +395,22 @@ class Video:
391
395
  toggle (bool): The toggle value.
392
396
  '''
393
397
 
394
- mod = 'add' if toggle else 'remove'
398
+ if toggle:
399
+ res = self.client.call(f'api/v1/playlist/video_add_watchlater', 'POST', dict(
400
+ vid=self.id,
401
+ token=self.client._granted_token
402
+ ))
403
+ return res.is_success
395
404
 
396
- res = self.client.call(f'playlist/video_{mod}_watchlater', 'POST', dict(
397
- vid=self.id,
398
- token=self.client._granted_token
399
- ))
405
+ else:
406
+ res = self.client.call(
407
+ "api/v1/playlist/video_remove_watchlater",
408
+ method="DELETE",
409
+ params={"vid": str(self.id), "token": str(self.client._granted_token)},
410
+ headers={"Accept": "application/json"},
411
+ )
412
+ return res.is_success
400
413
 
401
- self._assert_internal_success(res.json())
402
414
 
403
415
  # === Data properties === #
404
416
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phub
3
- Version: 4.8.5
3
+ Version: 4.8.7
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
@@ -1,13 +1,13 @@
1
1
  phub/__init__.py,sha256=tEWpP7XSkDB9_M5iJ1XHSgpJ6g4olWqYTX8f9IBpIAA,635
2
2
  phub/__main__.py,sha256=nP5IffsxbcFzPdGkMWky4fs647NOswW9DT-S5AcLQtU,4028
3
- phub/consts.py,sha256=a-okcZtwtSDmt4eub_acE1xWg1Fqxm1DZ9yy7aVGvM0,12453
4
- phub/core.py,sha256=_5iMMcvnt9Ue-1YY1u0Nlc4Sra-VMHFoiLcxIaUSLSM,18441
3
+ phub/consts.py,sha256=5CAmnpxAzX_-S2Mj6WlmpCgy10opck8ejQsbDYanN-8,12454
4
+ phub/core.py,sha256=ZZXGXQpF74MuI9bft8op1vlo_Ia6AQBH5jdqM8xNAAI,18576
5
5
  phub/errors.py,sha256=KiNt_4T4ffzgL-2iIfD8qhIHN_5DeKV4FLPcY72sOw8,1822
6
6
  phub/literals.py,sha256=ZnRnn5hJNI3hM6aj2YxsxPANUR-PCqfE2SuQGD8_Yq4,10794
7
7
  phub/utils.py,sha256=MYPYvpLrWAYXcwpSUJnRWvFNP0N9iOyLxkzaJFsk8GA,6582
8
8
  phub/modules/__init__.py,sha256=h8BQjvxnqCEXxDCn7iDvnGLv0ZF_lE0dFlI7HVkzN5A,133
9
9
  phub/modules/display.py,sha256=qOUaDGZJbGp80JAqPu_T__F2Mzwr3FBRnhrAdYdVjoE,2444
10
- phub/modules/parser.py,sha256=v2iDYAZB6VQ6KvKR_Oe1Cs5Du42W0yNFvtliJKxbZdI,2337
10
+ phub/modules/parser.py,sha256=-7q3818wqDX1YMQouY9JguHDaULYiXFkL6rheHf-Big,2360
11
11
  phub/modules/rss.py,sha256=j666dZenn3tWgLVXd2U3ox2-tWyUynFXuArzG2bmOFc,980
12
12
  phub/objects/__init__.py,sha256=BHOythbS-r01YKYSxtExBlJZYF38hkp85aLAoVQfDd4,446
13
13
  phub/objects/account.py,sha256=B1hSHmYHip08Gy-TdVmYq25iAA8rjdVuzwwkpjGjl8c,6044
@@ -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=gALFeOQA48loUStLA_d9npQHIAkw0CdTAIOQ_h_tFuA,11811
19
19
  phub/objects/user.py,sha256=pIumIGC_MQXQ-hjzf_0c0I_egL4WziHrh2e8XegArEc,8161
20
- phub/objects/video.py,sha256=0XJL-PP8HVqb2uUexIMZVfQ29-qGEeb60_yVoj3RLuc,19169
20
+ phub/objects/video.py,sha256=OVzeqQUQJfTMvtPXKARB-ZbmcPHZ3zhY2e04ekodJbA,19524
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
26
  phub/tests/test_video.py,sha256=4E70tiza45byMFIrjBdnpP3xOSyk1YKoTGNP4_QTI0E,1465
27
- phub-4.8.5.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
28
- phub-4.8.5.dist-info/METADATA,sha256=K7OEBgDD9c1VArJvma_ccZmUZ0yi177cSxbUmIMon8k,41758
29
- phub-4.8.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- phub-4.8.5.dist-info/entry_points.txt,sha256=oxL1BvDV19M1IGLgwFElgb37PlmGnblDBEfMwx3x6u8,44
31
- phub-4.8.5.dist-info/top_level.txt,sha256=xqJ5Lg28Ba-pgvXf8qwpTFurW3neZhguNd8bhbQonZo,5
32
- phub-4.8.5.dist-info/RECORD,,
27
+ phub-4.8.7.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
28
+ phub-4.8.7.dist-info/METADATA,sha256=G-Od1A2D4sHRysnOv546u18w-yXUbWyu7Ojr0Kfgqrg,41758
29
+ phub-4.8.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ phub-4.8.7.dist-info/entry_points.txt,sha256=oxL1BvDV19M1IGLgwFElgb37PlmGnblDBEfMwx3x6u8,44
31
+ phub-4.8.7.dist-info/top_level.txt,sha256=xqJ5Lg28Ba-pgvXf8qwpTFurW3neZhguNd8bhbQonZo,5
32
+ phub-4.8.7.dist-info/RECORD,,
File without changes