DrKain / scrape-youtube

A lightning fast package to scrape YouTube search results
MIT License
112 stars 30 forks source link

Filter videos by hashtag #54

Closed jinseok9338 closed 2 years ago

jinseok9338 commented 2 years ago

I know that you can filter whether the video is live or not and so on but it will be helpful to add features to filter only shorts too.

it will be easy since the shorts video has shorts in their url

DrKain commented 2 years ago

What are shorts? I've not heard of this before. If you're referring to the video duration YouTube only has a few filters for these:

Duration Custom SP
under 4 minutes EgIYAQ%253D%253D
4-20 minutes EgIYAw%253D%253D
over 20 minutes EgIYAg%253D%253D
DrKain commented 2 years ago

After digging around it looks like you're talking about YouTube hashtags. You can simply add "#shorts" to the end of any search query. The results will be videos under 1 minute with #shorts in the title.

The quotes are required for a strict search. Example:

youtube.search('anime "#shorts"', options).then(console.log);
DrKain commented 2 years ago

Unfortunately there's no YouTube filter for these, nor is there any identifiable information in the render data. As far as I'm aware there's no reliable method of searching videos by hashtag either, so a 'type' filter is not possible right now. You'll have to stick with the method above for shorts.