Table of Contents

  1. Downloading all playlists
  2. Finding a channel’s playlists


Archiving channels with youtube-dl

Guide, Shell

July 28, 2021

Things that are online may spontaneously disappear, or may be not-so-spontaneously removed by different companies. What if you want to archive your favorite Youtube channel so that, in case it gets deleted, you still have the videos? You can do this easily with youtube-dl.

Before I continue any further, a disclaimer: I don’t condone or encourage downloading copyrighted material. If you don’t have the rights to something on Youtube, I have to tell you not to download it.

With that out of the way, let’s get to the actual guide. First, make sure you have youtube-dl installed. You can get the official version, but personally I use yt-dlp. yt-dlp is a maintained fork of youtube-dlc (which is in turn a fork of youtube-dl), and includes numerous community improvements; consult its Github repo (linked in the previous sentence and in the sidebar) for more details.

Downloading all playlists

As an example for this guide, let’s say I want to download Doc Schuster’s playlists (which is a fantastic physics channel, I owe a large part of my IB HL Physics grade to his videos). Let’s also say I created a directory for this channel at /mnt/video-storage/doc-schuster. Here’s the command I’d use to download all playlists on the channel:

youtube-dl -ciw -f bestaudio+bestvideo -o '/mnt/video-storage/doc-schuster/%(playlist)s/%(playlist_index)s_%(title)s_%(id)s.%(ext)s' --yes-playlist -r 2.5M

This is what the command does:

I recommend running this in a tmux session, so you can detach/reattach terminals as needed. If you want to download the whole channel, use the link to the channel instead (i.e. omit the /playlists and the end of the URL).

Finding a channel’s playlists

You might also want to see which playlists a channel has. If you have jq (a JSON parser/processor) installed, you can use this to get a tab-separated list of playlist names and URLs:

youtube-dl --dump-json --flat-playlist | jq -s 'map([.title, .url] | @tsv) | .[]'

Here’s the breakdown:

Then you can select the playlists that you want, and pass them to youtube-dl.