Tuesday, April 23, 2019

My youtube-dl configuration / useful options

Here's my youtube-dl configuration (details about where to place the config-file below are here).
Of course you can also use any of these options in the command-line, without creating a dedicated config-file.


###############################################################
# This writes the video-IDs of the videos that have been downloaded
# into a file called archive.txt. Subsequent runs of youtube-dl will
# check that file and will skip videos that have already been downloaded.
--download-archive archive.txt

# Download subtitles in English, German, French and Amharic (if available)
# Note that these refer to human-generated subtitles (for example if
# the video-creator wrote them).
--write-sub --sub-lang en,de,fr,am

# Download subtitles in English, German, French and Amharic (if available)
# Note that these refer to Youtube's auto-generated subtitles (which can
# be hit or miss, but it's better than nothing, especially for English).
--write-auto-sub --sub-lang en,de,fr,am

# Get the best video quality available, but only up to 1080p.
# (with 4K videos, you'll end up with HUGE files, which one may
# want to avoid
-f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]'

###############################################################
When downloading a playlist, I find it convenient to have the files with the playlist-order in the filename, since that's the way I like to sort them. To change the filename-template, use the "-o" option. For example, if this is what I want the 3rd song's filename in my playlist to look like:
3_NiceVideo_VideoID.mp4
This command will accomplish that:
youtube-dl -o "%(playlist_index)s_%(title)s_%(id)s.%(ext)s" 
For more info on output-templates (the stuff behind the "-o", read more here). Just in case someone finds this useful: Here's a web-based subtitle-scraper for YouTube: https://www.diycaptions.com/ And in the unlikely case one would want to download comments from a video, I haven't found a way to do this through the command-line. But I found this web-based-commend-scraper which seems to work fine: http://ytcomments.klostermann.ca/