icon fullempty.sh

Archiving videos comprehensively with youtube-dl

2019-04-23

I'm an avid fan of the youtube-dl project. By now most people know that youtube-dl can retrieve videos on nearly any website, especially if you're willing to pop open your browser's web inspector looking for .m3u8 playlists. But personally, I find it incredibly useful as a tool for archiving videos more comprehensively. Some of youtube-dl's extended features facilitate this, and its man page is intensely detailed, in stark contrast to a lot of newer projects.

Previously, I relied on bash aliases for default options for youtube-dl, but finally noticed that you can simply provide a config file, .config/youtube-dl/config. Its format is simply the switches you'd normally provide to youtube-dl, except one per line.

Especially in the case of Youtube, youtube-dl provides several options for archiving not just the video, but any metadata, subtitles, annotations (despite being deprecated/removed from Youtube), and timestamps. My config is as follows:

-i
--write-sub
--write-auto-sub
--sub-lang en
--download-archive ~/.ytdl-archive
--restrict-filenames
--write-description
--write-info-json
--write-annotations
--write-thumbnail
-o '~/save/yt/%(uploader)s/%(uploader)s_%(title)s_%(id)s_%(upload_date)s.%(ext)s'

These options not only save automatically generated subtitles, but those uploaded by users. My filename format is comprehensive for later search and with a little work, parsing. Another notable option is the --download-archive switch. This specifies a file in which downloaded videos' IDs are recorded. If you attempt to download the same video a second time, youtube-dl will check this file if it was downloaded and refuse to do so if you already have.

With these options, the videos will also be saved in a subdirectory named after the original uploader.

« Back
© 2019 Derek Arnold
This page modified on Tue Apr 23 21:46:48 CDT 2019