Closed iced-queen closed 1 year ago
Seems this is the same issue as #71, and it works on my side. I suspect you got a different DOM because of IP (Europe?) or AB Testing.
Can you paste the HTML you get on the search page here or send it to my email? So that I can analyze it.
Seems this is the same issue as #71, and it works on my side. I suspect you got a different DOM because of IP (Europe?) or AB Testing.
Can you paste the HTML you get on the search page here or send it to my email? So that I can analyze it.
What do you mean the HTML I get?
{
data: [],
paging: { current: NaN, maxPage: NaN, isEnd: true },
counting: { from: 0, to: 0, total: 0 }
}
Is all it returns. :)
Oh, do you mean you want me to go to https://www.pornhub.com/
and send you the HTML in "inspect"?
If so; pornhub.zip
@chocobearxo I need this
view-source:https://www.pornhub.com/video/search?search=ass
I suspect your ph instance got a shadow ban or something. The HTML you gave me is correct. But I think the content you get when you call .searchVideo
might be empty or some warning text.
I suspect your ph instance got a shadow ban or something. The HTML you gave me is correct. But I think the content you get when you call
.searchVideo
might be empty or some warning text.
So? 😅 Is it an issue in the library or?
I'm still figuring out what it can be. I will improve the logging and error detection in the library so that you can monitor what happened.
So it worked before, but not anymore recently? What is the current status?
Guys, maybe I don't understand something, but you just ignore cookies inside buildRequest function. In the end request is always send with empty headers. I just had a problem that all requests return empty results because of age verification.
buildRequest<U extends Record<string, any>, T>(method: 'get' | 'post' | 'post-form', url: string, data?: U): Promise<T> {
const headers: HeadersInit = {}
const opts: RequestInit = { method, headers }
if (method === 'post') {
headers['Content-Type'] = 'application/json'
opts.body = JSON.stringify(data)
}
if (method === 'post-form') {
// headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
opts.method = 'post'
if (data) opts.body = this.buildParams<U>(data)
}
return this.fetch(url, opts)
.then(res => this.toJson(res) as T)
.catch(err => Promise.reject(err))
}
As soon as I added locally smth like this:
const headers = { cookie: Object.entries(this.getCookies()).map(pair =>
${pair[0]}=${pair[1]}).join('; ')};
Everything started to work fine
Man 😠You are right. I can't believe this has been wrong for so long.
This request module is like shit 😅 I will reimplement it sometime.
@DummyYummy @chocobearxo v1.7.1 released. Let me know if it works.
Seems like searchVideo()
works, but video()
still throws an error that I mentioned in #80
@chocobearxo Can you verify this with 1.7.4?
@chocobearxo Can you verify this with 1.7.4?
Well I've tested it a lot now and the only function that still seems to have issues is randomVideo()
but like stated in another issue regarding that, that's an issue on Pornhub's end, not the library, so in short; yeah I pretty much think 1.7.4
fixed the issues. 😄
For others, this can be easily fixed with a while
loop if you wanna use that.
let res = await pornhub.randomVideo()
while (res.id === 'https://www.pornhub.com/') {
res = await pornhub.randomVideo()
}
// Continue whatever you're doing
So now you can easily focus on the other issues/suggestions whenever you've got time for that. 😊
Whatever what I search for, the
searchVideo
function always returnsI even tried to search for something as simple as "ass" which Pornhub should contain lots of xD, but no results?