TimeForANinja / node-ytsr

Do anonymous YouTube search requests.
MIT License
284 stars 66 forks source link

Output array include type: "shelf" when using getFilters with get('Type').get('Video') #190

Closed wanaimnn closed 1 year ago

wanaimnn commented 1 year ago

I thought the get('Type').get('Video') method is only filtering type: "video" only

import ytsr from 'ytsr';

   const query = 'vevo'; // using query "vevo" as example
    const filters = await ytsr.getFilters(query); 
    const videoFilter = filters.get('Type').get('Video'); 

    const options = {
      limit: 20, 
    }
    const searchResults = await ytsr(videoFilter.url, options);
    console.log(searchResults);

The output in arrays include type: "shelf" if you search it

{
    "type": "shelf",
    "title": "Shorts",
    "items": []
  }

Is it possible to only getting type:"video" only and exclude the type: "shelf"?

TimeForANinja commented 1 year ago

the filters.get('Type').get('Video'); is altering the query send to youtube if youtube decides to serve you videos in a shelf the library does the same

what you can obviously do is do the filtering yourself or flatten all shelfs (or even all elements with a items key) into a single list of videos

jnomikos commented 9 months ago

I ran into the same issue. I will do some brute force filtering rather than relying on YouTube