EchterAlsFake / PHUB

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

Pattern ... failed #46

Closed slavikfoxy closed 7 months ago

slavikfoxy commented 9 months ago

Pattern id=\"(.?)\".?-vkey=\"(.?)\".?title=\"(.?)\".?src=\"(.?)\".?-mediabook=\"(.?)\".?marker-overlays.?>(.?)</div failed Traceback (most recent call last): File "C:\Users\oliyn\OneDrive\Documents\ghub\CheckMissVideo.py", line 191, in imput() File "C:\Users\oliyn\OneDrive\Documents\ghub\CheckMissVideo.py", line 57, in imput for i, video in enumerate(client.account.watched): File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 109, in iter for item in page: File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 335, in _iter_page wrapped: QueryItem = self._parse_item(item) File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 305, in _parse_item data = self._eval_video(raw) File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 298, in _eval_video data = {k: v for k, v in zip(keys, consts.re.eval_video(raw))} | {'raw': raw} File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\consts.py", line 86, in wrapper raise errors.RegexError('Find regex failed.') phub.errors.RegexError: Find regex failed.

how can I skip this error in the loop for i, video in enumerate(client.account.watched)

slavikfoxy commented 9 months ago

Can I access the list of my videos in the playlist?

Egsagon commented 9 months ago

Hi, you can skip errors by using phub.utils.suppress. To access the lists of the videos you created in the playlist, you can simply filter videos that have you as an author:

for video in client.account.watched.sample(filter = lambda v: v.author.name == 'your-name'):
    ...

Direct user objects comparisons is something that should be added in the future.

Concerning the regex error, can you share what videos/types raise these errors, so the project can be updated?

slavikfoxy commented 9 months ago

593 594 595 Pattern id=\"(.?)\".?-vkey=\"(.?)\".?title=\"(.?)\".?src=\"(.?)\".?-mediabook=\"(.?)\".?marker-overlays.?>(.?)</div failed Traceback (most recent call last): File "C:\Users\oliyn\OneDrive\Documents\ghub\CheckMissVideo.py", line 195, in input() File "C:\Users\oliyn\OneDrive\Documents\ghub\CheckMissVideo.py", line 59, in input for video in suppress(client.account.watched): File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\utils.py", line 229, in suppress raise err File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\utils.py", line 218, in suppress item = next(iterator) ^^^^^^^^^^^^^^ File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 109, in iter for item in page: File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 335, in _iter_page wrapped: QueryItem = self._parse_item(item) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 305, in _parse_item data = self._eval_video(raw) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 298, in _eval_video data = {k: v for k, v in zip(keys, consts.re.eval_video(raw))} | {'raw': raw} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\consts.py", line 86, in wrapper raise errors.RegexError('Find regex failed.') phub.errors.RegexError: Find regex failed. [Finished in 29.7s]

phub.utils.suppress did not help

Egsagon commented 9 months ago

You need to specify which error you need to supress. In your case, phub.errors.RegexError

slavikfoxy commented 9 months ago

I figured out how to use suppress, for video in suppress(client.account.watched, phub.errors.RegexError):but it exits the loop Pattern [91mid=\"(.?)\".?-vkey=\"(.?)\".?title=\"(.?)\".?src=\"(.?)\".?-mediabook=\"(.?)\".?marker-overlays.?>(.?)</div[0m failed Suppressing the error Find regex failed..: RegexError('Find regex failed.') and the function for video in (client.account.watched.sample(filter = lambda v: v.author.name == 'MyNaMe')): print(f'{video.title}'): does not print any result

Egsagon commented 9 months ago

Make sure you are using the right name (e.g. from client.account.name) and you have watched your videos.

slavikfoxy commented 9 months ago
image

I can't get more than 47 videos, is it just me? it happened 3 days ago.

Egsagon commented 9 months ago

It's not just you. My history got striped out too. It's a problem on Pornhub side, and it sucks.

Egsagon commented 9 months ago

Concerning this error, i cannot work on PHUB anymore so you will have to see with @EchterAlsFake. I still believe this was due to some pornhub videos you have watched in the past not being available anymore on pornhub (banned from your country, removed by pornhub or author, etc.). This is a pain in the ass to debug since it depends only on your history. That's why i implemented VideoError and utils.supress, which apparently stopped working for some reason. Anyway if your history remains deleted, at least you won't have the problem (for now).

slavikfoxy commented 9 months ago
image

I think I broke my account )

Egsagon commented 9 months ago

at least there are no errors

EchterAlsFake commented 7 months ago

@slavikfoxy

Hey, if you are still there... If it would be possible for you, please update to the newest PHUB release and execute your script from february once again. If it still gives you the Pattern failed error, please run the same script again, but print out the URLs at the beginning, so that we can identify the exact video where it fails. This would be great, thank you :)

slavikfoxy commented 7 months ago
  1. https://www.pornhub.com/view_video.php?viewkey=65767498dbb2f
  2. https://www.pornhub.com/view_video.php?viewkey=65a9177237741 Pattern failed Traceback (most recent call last): File "C:\Users\oliyn\OneDrive\Documents\PYTHON PROJEKT\4.4\0CheckMissVideo.py", line 35, in imput() File "C:\Users\oliyn\OneDrive\Documents\PYTHON PROJEKT\4.4\0CheckMissVideo.py", line 28, in imput raise e File "C:\Users\oliyn\OneDrive\Documents\PYTHON PROJEKT\4.4\0CheckMissVideo.py", line 20, in imput for i, video in enumerate(client.account.watched): File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 134, in iter for item in page: File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 331, in _iter_page wrapped: QueryItem = self._parse_item(item) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 304, in _parse_item data = self._eval_video(raw) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 297, in _eval_video data = {k: v for k, v in zip(keys, consts.re.eval_video(raw))} | {'raw': raw} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\consts.py", line 113, in wrapper _throw_re_error(pattern) File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\consts.py", line 78, in _throw_re_error raise errors.RegexError(f'Regex <{regex_name}> failed.') phub.errors.RegexError: Regex failed. [Finished in 20.1s]
slavikfoxy commented 7 months ago

What code should I write to get the url of 926 videos?

slavikfoxy commented 7 months ago

phub.Video(key=65ac5d1a2b3d4), on version 4.2.0 the pattern works

image
Egsagon commented 7 months ago

Hey, this should be fixed now. Please update from the latest commit and tell us if it works.