Trying to download 100+ videos, most of which are available in "-f 43 format" I do sometimes get an error "ERROR: requested format not available".
So I'd like to have a loop that in those cases tries the same download, but in "-f 18" format (which is similar enough).
I think this should be possible, probably in bash, but I have no clear idea how. Any help is greatly appreciated!
There is no need for external coding; youtube-dl includes this functionality natively. Simply add slashes in your -f
parameter. For instance, if you want format 43, failing that 18, and failing that simply the best available single file, call youtube-dl like this:
youtube-dl -f 43/18/best https://www.youtube.com/watch?v=BaW_jenozKc
For more information, refer to the official documentation on format selection.