Can I download videos from a YouTube search query using youtube-dl?

There is a built-in search option for youtube-dl. Old way:

youtube-dl "gvsearch1:how to create android app in app studio"

The argument is: gvsearchX, where gvsearch means use google and X is the number of results you want to download. So the above will search for "how to create android app in app studio" and download the first result.

(Update!) Seems like ytsearch (youtube search) is the better approach now:

youtube-dl "ytsearch1:how to create android app in app studio"

Yes, it is possible to download videos from search query on YouTube.

Adding &page=1 to the previous query allowed the download to go through.

https://www.youtube.com/results?search_query=how+to+create+android+app+in+android+studio&page=1

page 1


Besides the before-mentioned possibility to use google video search via gvsearch you can also search directly on YouTube:

youtube-dl "ytsearch1:how to create android app in app studio"

I didn't find it anywhere documented, but recently an error message pointed me into the right direction.