Coder Social home page Coder Social logo

echteralsfake / phub Goto Github PK

View Code? Open in Web Editor NEW
64.0 64.0 22.0 7.71 MB

A lightweight API for Pornhub

Home Page: https://phub.rtfd.io

License: GNU General Public License v3.0

Python 99.88% Shell 0.12%
api downloader porn-download pornhub pornhub-api pornhub-downloader pornhub-scraper pornhubapi pornography python python3 scrapper-api webscraper xxx

phub's Introduction

🌟 EchterAlsFake 🌟

🛠️ Digital Craftsman (Content Creator | Developer | Student | Life Enjoyer) 🎓

👋 Hey there! I'm Johannes, a 16-year-old student from the Liborius-Gymnasium in Germany. My coding journey began at 12, and ever since, I've been avidly pushing commits and working on various projects. 🚀 My passion lies in developing graphical user interfaces and supporting APIs, with all my projects being open-source under the (L)GPL License. 🌐 Although I'm not frequently active on my YouTube Channel EchterAlsFake, I'm planning to ramp up my content creation soon!

Apart from coding, I occasionally delve into Cybersecurity, expanding my knowledge and skills. 🛡️

What I Believe:

  • Collaboration is key to success, and I'm always open to it. Let's create something amazing together! 🤝
  • Positivity over saltiness any day! If you've got an issue, just open it up. We're all here to learn and grow. 😄
  • Stand with Ukraine! 🇺🇦
  • FUCK AFD

📬 Reach Out to Me:

Johannes Habel's GitHub stats

🎵 Let's Talk Music

I'm a big fan of music, and here's a snapshot of my favorite artists and songs according to Spotify and me. Music is the rhythm to code by! 🎶

spotify-github-profile

🎤 Favorite Artists (Spotify's Choice):

🎵 Favorite Songs (My Picks):

(Last updated on: 16th of March 2024)

🧰 Languages and Tools

Git

Linux

Python

Bash

GitHub

Qt

PyCharm

Android


Inspiration Credit: The amazing ForrestKnight
(Don't forget to check out his YouTube channel!)

phub's People

Contributors

echteralsfake avatar egsago-n avatar egsagon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

phub's Issues

Is there a way to list videos from channels by country

i see you docs but no find how to list video by channel and from country

example

video = client.FindVideosByChannelCountry("india")

then list all videos from channels from india country

and how to list channels and all videos from channels

channels = client.VideosfromChannel("My channel")

Index Error on get_user.videos

Hi,

One of my users had an Issue with the model / user function. He tried to get all videos from this model:

https://cn.pornhub.com/model/ada-kham

Everything worked fine, but after 61 fetched videos an Index Error appeared:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/test.py", line 7, in <module>
    for video in videos:
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 77, in __next__
    return self.get(self.iter_index)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/query.py", line 90, in get
    raw = self._get_page(index // self.PAGE_LENGTH)[index % self.PAGE_LENGTH]
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range

Sometimes the Index Error appears and sometimes it doesn't, but it ends in 61 videos. I tested it with multiple channels and sometimes it is able to fetch all videos. (For example Elly Clutch, but still thows the Index Error.)

Error with the callback

Hi,

I got this error, when downloading a video with the default downloader:

Traceback (most recent call last):
 File "/home/asuna/PycharmProjects/Porn_Fetch/Porn_Fetch.py", line 221, in run
   self.video.download(downloader=default, display=self.callback, quality=self.quality, path=self.output_path)
 File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/video.py", line 204, in download
   downloader(
 File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/modules/download.py", line 70, in default
   callback(i + 1, length)
TypeError: 'Callback' object is not callable

Using newest commits from your repo.

AttributeError NoneType object has no attribute "url" in the Account function

Hi again,

When trying to login with my account I got this error here:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/Porn_Fetch.py", line 767, in login
    self.client = Client(username=username, password=password, language=self.api_language, delay=self.delay)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/core.py", line 67, in __init__
    self.login()
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/core.py", line 134, in login
    self.account.connect(data)
  File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/objects/account.py", line 68, in connect
    if not 'user/' in self.user.url:
                      ^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'url'

Using the function from my GUI:

        try:
            if not self.custom_language:
                self.get_client_language()

            self.client = Client(username=username, password=password, language=self.api_language, delay=self.delay)
            self.ui.lineedit_account_status.setText(f"Logged in as: {self.client.account.name}")
            self.ui.groupBox_7.setEnabled(True)

        except phub.errors.LoginFailed:
            logging(msg="Login Failed. Check credentials!", level="1")
            ui_popup("Login Failed. Check credentials!")

        except phub.errors.AlreadyLoggedIn:
            logging(msg="Already logged in", level="1")
            ui_popup("Already logged in.")```

[Feature] messaging users

From what I can see from the docs & codebase, currently messaging other users is not supported.

Is this sth planned in the roadmap? Or is this sth not at all planned due to possible ethical concerns?

Feature Request: get total length of segments before download

Hi,

For a certain function for my GUI I need to get the total length of segments, but without downloading the video. Would it be possible for you to create such a function in the video object?

If a user downloads multiple videos at once, I want to show the total progress and I'd need to add the length of segments for all videos before downloading it.

why error after search

i get error when search . its normal or not .

C:\Users\LENOVO\Pictures\mainan\webdood>python -m phub search toge
ph5f0310a388dd4 - ngentot toge kaya raya
ph5eabc148e9cb3 - พี่กับน้องเล่นเย็ดกันParents are not at home. try playing sex toge
Invalid API response from https://www.pornhub.com/webmasters/search?search=toge&page={page}
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub_main
.py", line 84, in
cli()
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 783, in invoke
return _callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub_main
.py", line 72, in search
for video in client.search(entry).sample(int(max)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub\objects\query.py", line 131, in sample
for item in self:
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub\objects\query.py", line 108, in iter
for page in self.pages:
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub\objects\query.py", line 95, in pages
page = self._get_page(i)
^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub\objects\query.py", line 178, in _get_page
els = self._parse_page(raw)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub\objects\query.py", line 263, in _parse_page
raise errors.ParsingError('Invalid API response')
phub.errors.ParsingError: Invalid API response

Issue with search filters

Hi,

I don't know if I just didn't understand how to use the search filters, but when using them I got this error:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/Porn_Fetch.py", line 626, in search_videos
    query_object = self.client.search(query, locals.Category.ASIAN + locals.Production.PROFESSIONAL + self.sort + self.sort_time - self.excluded_categories_filter)
                                             ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'Param' and 'Param'

search options not working properly

Hi there,

so here's a minimal example:

import phub

client = phub.Client()

query = client.search(query=None, category='amateur', sort='views', production='professional')

for video in query.sample(max=10):
    print(video.title, video.views)

Results:

AnalTrixxx - Tattooed Alt Spinner Paisley Paige Anal Fucked Hard 54681
CEI Cum Eating Encouragement Instruction JOI POV Positive Femdom 146748
Colombian Beauty Mary Gomez Meets And Fucked Her New Boyfriend - MAMACITAZ 11263
SANTA CAME TO FUCK IN MY HOUSE 57502
Sissy Boy Crossdressing And Bisexual Domination Porn 883
Заехал в гости , малыха оказалась гостеприимной 83819
WOWGIRLS Very sensual lesbian scene starring amazing girls Evelin Elle and Molly Devon 148789
Erotic oiled massage squirt shaking orgasm 111685
Sweet Heart Video - April Olsen Tells Harley Haze To Dump Their Boyfriends & Play With Each Other 102658
NicoRD fucks my stepsister on my vacation ft Lynnscream ANAL 70149

switching production to 'homemade' gives the same results:

AnalTrixxx - Tattooed Alt Spinner Paisley Paige Anal Fucked Hard 54681
CEI Cum Eating Encouragement Instruction JOI POV Positive Femdom 146748
Colombian Beauty Mary Gomez Meets And Fucked Her New Boyfriend - MAMACITAZ 11263
SANTA CAME TO FUCK IN MY HOUSE 57502
Sissy Boy Crossdressing And Bisexual Domination Porn 883
Заехал в гости , малыха оказалась гостеприимной 83819
WOWGIRLS Very sensual lesbian scene starring amazing girls Evelin Elle and Molly Devon 148789
Erotic oiled massage squirt shaking orgasm 118011
Sweet Heart Video - April Olsen Tells Harley Haze To Dump Their Boyfriends & Play With Each Other 102658
NicoRD fucks my stepsister on my vacation ft Lynnscream ANAL 70149

Also, notice that they're not really sorted by views

Error when getting multiple video titles

When attempting to grab video titles by iterating through a list of URLs, the following error is shown once it has successfully grabbed 20 titles:

Traceback (most recent call last):
File "/home/brightpepe/Documents/Code/test_ph.py", line 6, in
video = client.get('https://www.pornhub.com' + al)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/brightpepe/.local/lib/python3.11/site-packages/phub/core.py", line 288, in get
return classes.Video(client = self, url = url, preload = preload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/brightpepe/.local/lib/python3.11/site-packages/phub/classes.py", line 179, in init
self.refresh()
File "/home/brightpepe/.local/lib/python3.11/site-packages/phub/classes.py", line 193, in refresh
self.data = parser.resolve(self.page)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/brightpepe/.local/lib/python3.11/site-packages/phub/parser.py", line 22, in resolve
flash, ctx = consts.regexes.video_flashvar(html)[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Already updated to the latest version of the module.

Example code attached
example.txt

various error during pip install and import

env
google colab

trial 1

step
pip install --upgrade git+https://github.com/EchterAlsFake/[email protected]

code
import phub

result

AttributeError                            Traceback (most recent call last)
[<ipython-input-5-09043198e867>](https://localhost:8080/#) in <cell line: 1>()
----> 1 import phub

2 frames
[/usr/local/lib/python3.10/dist-packages/phub/utils.py](https://localhost:8080/#) in <module>
    156             for key in keys}
    157 
--> 158 def suppress(gen: Iterable, errs: Exception | tuple[Exception] = errors.VideoError) -> Iterator:
    159     '''
    160     Set up a generator to bypass items that throw errors.

AttributeError: module 'phub.errors' has no attribute 'VideoError'

trial 2

execute
pip install --upgrade git+https://github.com/EchterAlsFake/PHUB.git

result

Collecting git+https://github.com/EchterAlsFake/PHUB.git
  Cloning https://github.com/EchterAlsFake/PHUB.git to /tmp/pip-req-build-sbfyqxqd
  Running command git clone --filter=blob:none --quiet https://github.com/EchterAlsFake/PHUB.git /tmp/pip-req-build-sbfyqxqd
  Resolved https://github.com/EchterAlsFake/PHUB.git to commit 7791aee995424e6a42206bd889659f99d007b566
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from phub==4.5.7) (2.31.0)
Collecting ffmpeg-progress-yield (from phub==4.5.7)
  Downloading ffmpeg_progress_yield-0.7.8-py2.py3-none-any.whl (10 kB)
INFO: pip is looking at multiple versions of phub to determine which version is compatible with other requirements. This could take a while.
ERROR: Package 'phub' requires a different Python: 3.10.12 not in '>=3.11'

trial 3

pip install --upgrade phub

result
still got the previous reported error #54

best regards

Issue with the model / user function

Hi,

I got this error when using the User function:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/Porn_Fetch.py", line 492, in user_channel
    total_videos = user_object.videos
                   ^^^^^^^^^^^^^^^^^^
  File "/usr/local/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/user.py", line 128, in videos
    return UQuery(client = self.client, args = url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Query.__init__() got an unexpected keyword argument 'args'

I tried it also with a simple test script:

from phub import Client

c = Client()
x = c.get_user("https://www.pornhub.com/model/sofia-simens")
videos = x.videos

I've tried with different models using newest commit from your master branch

Query data structure flaw

Hey

So with 4.3.2 these properties are available on all video objects: watched, is_free_premium and preview (and some more but they are not related to the issue).

Normally, any property comes from one of these sources:

  • The Pornhub HubTraffic API, used by default whenever we can because it is lighter and contains enough data for basic needs
  • The Pornhub JSON video data that can be found on the page (using the parser.resolve function) which contains video data specifically for the video player (video segments, hotspots, thumbnails, etc.)
  • The page itself, see video.is_favorite

However, the properties i mentionned above are not available or too complicated to get from any of these sources. Instead, they only come from a query page.
For instance, the watched property comes from the "watched" tag you can see on a video thumbnail before clicking on it. Obviously, we can't get this information anywhere else from a query (unless we decide to irerate the entire account history).

If the video comes from a query

It is fine, the properties found on the query page are already stored and can be parsed on demand.

If the video does not come from a query (e.g. from Client.get)

PHUB will "simulate" a query. This is what the video._as_query property does (unless overrid by a query). It creates a temporary playlist on the client account, add the video to it and creates a new Query object with the playlist page.

Appart from the fact that this method is really not optimized (it costs 4 requests just to get whether one video has been watched), it is also not working because it uses the video page token, which means it needs to fetch the video page, and therefore consider the video as already watched, so the whole playlist procedure is useless.

This bug also affects other query-based properties, even though for some of them we can find a workaround (e.g. for the preview property, there might be a way to reconstruct the source url with the video key/id and other informations).

It might be possible to use a different token (like the query token) but this would require each video to store their queries.

What to do

You decide where these query properties should be implemented. Some of them (like watched and is_free_premium) are most likely to be used while iterating a query.

For exemple, as of now you can do:

for video in query.sample(filter = lambda vid: not vid.watched and vid.is_free_premium): ...

But another possible implementation could be:

for video in query.sample(watched = False, free_premium = True, ...): ...

This second implementation might look less user friendly because it has less of an OOP style but would make sure that these properties are safe to use. It would also make possible to not wrap each video in a Video object for optimization purposes since the query data we want is directly accessed from a regex (consts.re.eval_video).

Have fun

User 404 Error, when going to page 2

Hi,

from phub import Client

model = Client().get_user("https://de.pornhub.com/model/luna-okko")
videos = model.videos
for video in videos:
    print(video.title)

I get this error here:

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://www.pornhub.com/model/luna-okko/videos?page=2

But the first 32 videos were valid with no errors. I guess this is just a simpe error.

I used V4 with the newest commits.

re.error

re.error: unknown extension ?> at position 8

IndexError: list index out of range

import phub
import codecs
import shutil

from phub.locals import *
client = phub.Client('login', '1')

for i, video in enumerate(client.account.watched):
print(f'{i}. {video.image.url}')
END CODE

Traceback (most recent call last):
File "C:\Users\oliyn\OneDrive\Documents\PYTHON PROJEKT\import PH.py", line 10, in
for i, video in enumerate(client.account.liked):
File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 104, in next
return self.get(self.iter_index)
File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 127, in get
page = self._get_page(index // self.PAGE_LENGTH)
File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 169, in _get_page
return self._parse_page(raw)
File "C:\Users\oliyn\AppData\Local\Programs\Python\Python312\Lib\site-packages\phub\objects\query.py", line 271, in _parse_page
container = raw.split('class="container')[1]
IndexError: list index out of range

Quality options not working

Hi again,

I tried to download a video with the following code:

from phub import Client, Quality

url = "https://de.pornhub.com/view_video.php?viewkey=ph6376413191b91"

client = Client() # Tested also with client = Client(language="en"), makes no difference
video = client.get("https://de.pornhub.com/view_video.php?viewkey=ph6376413191b91")
title = video.title
video.download(quality=Quality.BEST, quiet=True, path=f"video/{title}.mp4")

But the quality doesn't change, no matter what option I choose. It's always the same file size. In the metadata it says: 854 x 480

I tested it with multiple URLs. I installed the newest version in a virtual environment with: pip install --upgrade git+https://github.com/Egsagon/PHUB.git

In the line 238 in the file utils.py you had a typo misstake:

    return str(self.vlaue)

I changed it to

    return str(self.value)  

But nothing changed.

Pattern ... failed

Pattern �[91mid="(.?)".?-vkey="(.?)".?title="(.?)".?src="(.?)".?-mediabook="(.?)".?marker-overlays.?>(.?)</div�[0m 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)

UnboundLocalError: cannot access local variable 'markers' where it is not associated with a value

Hi,

I tried accessing videos from a model but got this error:

200 https://www.pornhub.com/pornstar/alex-adams/videos
200 https://www.pornhub.com/pornstar/alex-adams/videos/upload
Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/tests.py", line 6, 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

Using this code as a test:

from phub import Client

c = Client()
user = c.get_user("https://de.pornhub.com/pornstar/alex-adams")
videos = user.videos
for video in videos:
    print(video.title)

phub.utils has no attribute "remove_video_ads"

Hey,

I got this error here:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/test.py", line 6, in <module>
    videos = client.get_user(url).videos
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/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/classes.py", line 127, in videos
    corrector = utils.remove_video_ads
                ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'phub.utils' has no attribute 'remove_video_ads'

This was the test code I used

import phub

url = "https://de.pornhub.com/model/realtelarilove" # Tried with multiple channels / models

client = phub.Client()
videos = client.get_user(url).videos

for video in videos:
    print(video.title)

API Version is the v3.2.2

how to get direct link url for download.

is there a way to just get the download url? and I don't want to download it on my computer. So I want to get the upload URL to paste on my video hosting

give me example code thx

The path param is not working correctly

Download is not working If the path starts with /

video.download(path='/tmp', quality=phub.Quality.HALF)

i've got

Downloading: 100% [206/206]Download failed [Errno 2] No such file or directory: 'tmp/64c3e5c82219e.mp4'

the / in the begining seems to be ignored

Failed to login

Hi
I am trying to login using this code snippet below.
client = phub.Client("username","password")

I am getting this error phub.errors.LoginFailed: Invalid entry. Use a valid email address to log in. I am using email as username.

I have also inspected the official pornhub api request to login. Please check below
image

As you can see the field name is email not username. So it might be a cause of this issue?

Thank you!

Question about Python 3.10 support

Hi,

I started developing for Android in my "android" branch and I already did a few test runs which were (after six hours) successfull. The problem is, that python-for-android officially supports Python 3.11, but in reality not :(

I needed to convert your project to Python 3.10 in order to get it working. I did this by removing the "Self" function which you imported from "typing". It's the only thing I needed and I ask you, if you can maybe do this for your future imports. It's not to much work, but always syncing with your repo and forking it manually would take a lot of time for me. I can understand if you say no, but it would be really nice.

Thanks :)

pop from an empty set

I'm trying to make an little API in flask and after using it 2 times i get

File "c:\Users\happy\Downloads\index.py", line 47, in get_videos

search_results = client.search(value)
                 ^^^^^^^^^^^^^^^^^^^^

File "C:\Users\happy\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub\core.py", line 244, in search

if (not (locals._allowed_sort_types in param)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\happy\AppData\Local\Programs\Python\Python311\Lib\site-packages\phub\objects\param.py", line 151, in __contains__

item_value = item_values.pop()
             ^^^^^^^^^^^^^^^^^

KeyError: 'pop from an empty set'

error: unknown extension ?> at position 8

code
import phub

result

error                                     Traceback (most recent call last)
[<ipython-input-37-09043198e867>](https://localhost:8080/#) in <cell line: 1>()
----> 1 import phub

11 frames
[/usr/lib/python3.10/sre_parse.py](https://localhost:8080/#) in _parse(source, state, verbose, nested, first)
    828                     group = None
    829                 else:
--> 830                     raise source.error("unknown extension ?" + char,
    831                                        len(char) + 1)
    832 

error: unknown extension ?> at position 8

best regards

ConnectionError: Request `{URL}` failed.

Hi,
I am getting this error while downloading the video. I used example code to test first
Code :

import phub

client = phub.Client()
# 
video = client.get('https://www.pornhub.org/view_video.php?viewkey=6440f82ee3f4f')
print('Downloading:', video.title)

# Download on working dir with best quality
video.download('.', quality = phub.Quality.BEST)

Error Response :

Traceback (most recent call last):
  File "D:\RandD\pornhub video downloader\test.py", line 5, in <module>
    video = client.get('https://www.pornhub.org/view_video.php?viewkey=6440f82ee3f4f')
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\phub\core.py", line 329, in get
    return classes.Video(client = self, url = url, preload = preload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\phub\classes.py", line 185, in __init__
    self.refresh()
  File "C:\Python311\Lib\site-packages\phub\classes.py", line 203, in refresh
    response = self.client._call('GET', self.url)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\phub\core.py", line 265, in _call
    raise ConnectionError(f'Request `{func}` failed.')
ConnectionError: Request `https://www.pornhub.org/view_video.php?viewkey=6440f82ee3f4f` failed.

Do i need to use any proxy server?

Error accessing the Account feed

Hi, I am trying to access the Account feed. I am using the latest commits from your repository.

Traceback (most recent call last):
  File "C:\Users\habel\PycharmProjects\Porn_Fetch\tests.py", line 11, in <module>
    print(c.account.feed)
          ^^^^^^^^^^^^^^
  File "C:\Users\habel\AppData\Local\Programs\Python\Python312\Lib\functools.py", line 995, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\habel\PycharmProjects\Porn_Fetch\venv\Lib\site-packages\phub\objects\account.py", line 145, in feed
    from .query import Feed
ImportError: cannot import name 'Feed' from 'phub.objects.query' (C:\Users\habel\PycharmProjects\Porn_Fetch\venv\Lib\site-packages\phub\objects\query.py)

Here's the code segment I use:

c = Client(username, password, language="en", delay=False, login=False)
c.login()

print(c.account.feed.feed)

TypeError: 'HTMLQuery' object is not subscriptable

Hi,

I am trying to use the search generator and iterate only until specific videos.

Here's an example:

c = Client(language="en")
search = c.search("Mia Khalifa", feature=HTMLQuery)

for video in search[0:10]:
    print(video.title)

I tried it with the HTMLQuery and with the JSONQuery

With both queries I got the TypeError.

(I know you have currently limited ability, so no rush about it :)

How to use This package without VPN or proxy

because pornhub and this package is blocked in my country .
how to use this package with proxy or if possible even without a proxy .
because i will make backend with this package for my web
thx

Multiple Issues

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.

Question for V4

So I see you are making a lot of progress on V4 and I want to ask if it's already ready to be used?
I want to start merging my GUI to v4, but I am not quite sure, because some exceptions are removed or not there and the Category object and the search filters are not there.

I am just wondering :)

Oh and, when I try to import phub I got this error:

Traceback (most recent call last):
File "/home/asuna/PycharmProjects/Porn_Fetch/src/cli.py", line 3, in
from phub import Client, Quality, errors
File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/init.py", line 8, in
from .core import Client
File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/core.py", line 4, in
from . import utils
File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/utils.py", line 9, in
from . import consts, locals
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/locals.py", line 7, in
from .objects import Param, NO_PARAM
ModuleNotFoundError: No module named 'phub.objects'

Not sure if it's because of my environment.

ERROR: Account already logged in

Hey,

I tried to log in with my testing account for my GUI and PHUB constantly raises the "raise consts.AlreadyLoggedIn('Account already connected.')" error. I never had a session before. Even with a VPN it didn't work. I am not quite sure why. I am using the newest 1.4 version directly from your repo.

Here's a short example code:

username = "..."
password = "...."

client = Client(username=username, password=password, language="en")
client.login()

(Using delay didn't change anything)

Issues with searching

Hi,

Okay so I did the mistake of not updating PHUB to your newest commits, which is why I got some of the errors, which you actually have fixed before. But I got some new errors, which I also want to report.

Searching

If I do a basic search like this:

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

I get an AssertionError: Account is not logged in which I am not sure if this is expected
or a mistake, because why would I need to log in to search.

If I log in to my account, it works, but it's extemely slow. With hub traffic and without.
Doesn't make a difference.

If I do a user search like above, but with c.search_user, I get this error:

Traceback (most recent call last):
  File "/home/asuna/PycharmProjects/Porn_Fetch/tests.py", line 6, in <module>
    for video in model:
  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._as_query['markers']):
                         ^^^^^^^^^^^^^^^^^
AttributeError: 'User' object has no attribute '_as_query'

(Also when I am logged in.)

Issue with search function

I'm using python 3.12

I just did

import phub
api = phub.Client()
hel = api.search('abela danger')

This works 1 or 2 times mostly after that it starts giving KeyError: 'pop from an empty set'

Any fix ?

List index out of range

Hey,

I got the following error:

Traceback (most recent call last):
 File "/home/asuna/PycharmProjects/Porn_Fetch/Porn_Fetch.py", line 449, in start
   video = self.test_video(url)
           ^^^^^^^^^^^^^^^^^^^^
 File "/home/asuna/PycharmProjects/Porn_Fetch/Porn_Fetch.py", line 434, in test_video
   self.video = self.client.get(url)
                ^^^^^^^^^^^^^^^^^^^^
 File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/core.py", line 328, in get
   return classes.Video(client = self, url = url, preload = preload)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/classes.py", line 185, in __init__
   self.refresh()
 File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/classes.py", line 206, in refresh
   self.data = parser.resolve(self)
               ^^^^^^^^^^^^^^^^^^^^
 File "/home/asuna/PycharmProjects/Porn_Fetch/venv/lib/python3.11/site-packages/phub/parser.py", line 80, in resolve
   script = video.page.split("flashvars_['nextVideo'];")[1].split('var nextVideoPlay')[0]
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

I tried with my UI and with your CLI script.

I used the V3.2.1 API version, but I haven't tried it with V4 as you said it would be unstable and not production ready.

Sorting doesn't work with use_hubtraffic=True

Hello nice library 👍

I tried using the sorting, but it always returns the same videos. Can it be that it is broken?
I use it the follwoing way. Is that correct?

query = client.search('query', Sort.VIDEO_MOST_RECENT, use_hubtraffic=True)

A small question maybe also: Is there a page attribute and how can i set it?
Keep it up 👍

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.