paaspaas00 / pornhubGrayjay

MIT License
11 stars 4 forks source link

Session cookie+token to fix search suggestions #1

Closed ghost closed 8 months ago

ghost commented 8 months ago

This adds basic session cookie header to all http.GET requests. The only things you need for a valid session are as follows:

  1. token
  2. session_id cookie (ss) in headers

I found the cookie using curl -sS -D - https://www.pornhub.com -o ph.html and trying every cookie in the response headers, and the only one that will get you a response other than just empty [] when you GET /video/search_autocomplete is "ss" aka session_id. Fortunately, this is inside the HTML itself (you can check ph.html output by the command) on every page load along with the token and is super easy to get. It's in meta[name="adsbytrafficjunkycontext"] in the data-info attribute.

Anyway, all this fixes search suggestions.

The tokens should last long enough that we don't need any additional logic, but if we do, it would be determining if a token expired when you do a request (in getPornhubContentData) and generating a new one.

paaspaas00 commented 8 months ago

@doombr1nger That's pretty cool! Thanks for finding this out and for the contribution!

paaspaas00 commented 8 months ago

You can also change the readme accordingly and add yourself to the contributors there (adding a paragraph with those). I like this to be a collaborative project! And again, thanks!