tombulled / innertube

Python Client for Google's Private InnerTube API. Works with YouTube, YouTube Music and more!
https://pypi.org/project/innertube/
MIT License
298 stars 20 forks source link

How do you filter searches using params? #47

Closed anmancontent closed 1 year ago

tombulled commented 1 year ago

is there any filters in search ? is there any example about params in search

Hi @anmancontent, thanks for opening this issue - filtering searches is indeed performed using search params, however from memory these vary slightly between each service.

To help understand your needs better, which service are you hoping to perform search requests against? (e.g. YouTube, YouTube Music, YouTube Kids, YouTube Studio etc.)

gensimone commented 1 year ago

How can I filter my search to only get YouTube playlists? (like this: https://www.youtube.com/watch?v=sWcLccMuCA8&list=PLiN-7mukU_RFooOYRV24OVaorPdJNcvSS&ab_channel=AphexTwin-Topic)

tombulled commented 1 year ago

Hi @steghy, I'll whip up an example for this now to show you how this works

tombulled commented 1 year ago

I've created the following example to hopefully help show how this works - https://github.com/tombulled/innertube/blob/9dc65252a5863bef63683a4e61ed813960cb65b8/examples/filter-search.py

You'll need to use your Browser's Developer Tools to intercept the requests sent to the InnerTube API by YouTube (or a proxy). Once you've done that you should be able to see which params to use based on the filters you've selected.

I believe the params are just URL-encoded Base64-encoded protobuf data (e.g. you can decode it using https://protobuf-decoder.netlify.app/), though it'd likely take a bit of reverse engineering to figure out appropriate field names for the data