JustalK / PORNHUB-API

A powerful and complete scrapper for the very famous pornhub.com. This javascript module for node give you the possibility, through an API with many options, to scrap any information out of a page or the search page.
MIT License
133 stars 28 forks source link

[BUG] Download_Urls returns an Error no matter what #22

Closed Arvejita closed 3 years ago

Arvejita commented 3 years ago

Describe the bug The 'download_urls' key on the video page function returns an error object: "{ error: 'An error ocurred' }". The thing is that if you provide any key, like "title" you get the title and an empty object "download_urls: {}". Also, if you dont provide a key it still returns an empty object "download_urls: {} ". I also looked into the test pages in the github repo and found that the download_urls key returns undefined (Look screenshots).

To Reproduce

const pornhub = require('@justalk/pornhub-api');
const url = 'http://pornhub.com/view_video.php?viewkey=ph5cacd6fc1e731';
const video = await pornhub.page(url, 'download_urls');

console.log(video)

Screenshots

Captura de pantalla 2020-10-26 154626 Captura de pantalla 2020-10-26 154619

Thank you for reading..

JustalK commented 3 years ago

Thank you for using my API.

Ok, I have noted the bug. I will fix it today when I got back from work. Should be fixed before Oct 28 2020.

JustalK commented 3 years ago

So, I have fixed this bug.

The first bug was on my side, nothing special:

 The thing is that if you provide any key, like "title" you get the title and an empty object "download_urls: {}".

The second one was two bugs in one.

First bug: you use a link that has a redirection. I did not know that Pornhub use also the http and redirect it to their https. I have a solution but it's a bit of work and I will do it tomorrow (28/10/2020). So instead of http://pornhub.com/view_video.php?viewkey=ph5cacd6fc1e731 use https://pornhub.com/view_video.php?viewkey=ph5cacd6fc1e731

Second bug: Apparently pornhub have made a little change in their API. They are now randomizing the place of the quality inside the link. See the differences:

Your link:

https........./720P_4000K_217429911.mp4?..........

The link of my test:

https.........../191018_1048_240P_1000K_72472822.mp4......

I have fixed the regex who was doing the parse. It should be ok now ;) I will fix the redirection tomorrow.

Arvejita commented 3 years ago

Ok, thank you.

JustalK commented 3 years ago

Ok, I have fixed this commit with my last pr.

This should now work :

const pornhub = require('@justalk/pornhub-api');
const url = 'http://pornhub.com/view_video.php?viewkey=ph5cacd6fc1e731';
const video = await pornhub.page(url, 'download_urls');

console.log(video)