EchterAlsFake / PHUB

A lightweight API for Pornhub
https://phub.rtfd.io
GNU General Public License v3.0
76 stars 25 forks source link

Multiple Issues #41

Closed EchterAlsFake closed 11 months ago

EchterAlsFake commented 11 months ago

Hi,

I've intensively tested a lot of PHUB features and found some errors in there.

Video Object:

Test URL: https://de.pornhub.com/view_video.php?viewkey=656fab8e1edef

Statement: print(video.pornstars)
Error:

Pornstars:
200 https://www.pornhub.com/pornstar/alex-adams
200 https://www.pornhub.com/pornstar/alex-adams
404 https://www.pornhub.com/channels/Alex-Adams
Could not guess type of Alex Adams
Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/tests.py", line 15, in <module>
    print(video.pornstars)
          ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/video.py", line 464, in pornstars
    return [User.get(self.client, ps['pornstar_name'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/video.py", line 464, in <listcomp>
    return [User.get(self.client, ps['pornstar_name'])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/user.py", line 149, in get
    raise errors.UserNotFound(f'User {user} not found.')
phub.errors.UserNotFound: User Alex Adams not found.

User Object

Test URL: https://de.pornhub.com/pornstar/alex-adams

Statement:

videos = user.videos
for video in videos:
    print(video.title)

Error:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/tests.py", line 24, in <module>
    for video in videos:
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 126, in __iter__
    for item in page:
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 35, in Page
    wrapped = query._parse_item(item)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 303, in _parse_item
    markers = ' '.join(consts.re.get_markers(markers)).split()
                                             ^^^^^^^
UnboundLocalError: cannot access local variable 'markers' where it is not associated with a value

Searching

Test Query: Mia Khalifa

Statement:

search = c.search("Mia Khalifa")
for video in search:
    print(video.title)

Error:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/tests.py", line 13, in <module>
    for video in search:
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 126, in __iter__
    for item in page:
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 35, in Page
    wrapped = query._parse_item(item)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 303, in _parse_item
    markers = ' '.join(consts.re.get_markers(markers)).split()
                                             ^^^^^^^
UnboundLocalError: cannot access local variable 'markers' where it is not associated with a value

(Tested with both hub_traffic booleans)

Statement:

search = c.search_user("Mia Khalifa")
for video in search:
    print(video.title)

Error:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/tests.py", line 13, in <module>
    for video in search:
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 126, in __iter__
    for item in page:
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 40, in Page
    and 'premiumIcon' in wrapped.data.get('query@markers')):
                         ^^^^^^^^^^^^
AttributeError: 'User' object has no attribute 'data'

Account

For the liked, and watched methods I got again the UnboundLocalError from #39
Recommended didn't return anything, although I am not sure if this isn't maybe an
Issue form PornHub, because I don't really use my account for private usage.

EchterAlsFake commented 11 months ago

Ah wait now shit I am stupid

Egsagon commented 11 months ago

Pretty sure recommended is disabled by default by pornhub, you have to enable it manually on the website.