← Back

Youtube Archival

I use the following config for downloading and archiving youtube videos for local storing and watching. Sometimes I refuse to trust even large corperations to keep data safe, so I feel so much safer having a local copy of the stuff I really enjoy.

Set the destination to anything you'd like (the quotes after the -P), obviously, and you can change up the subtitles downloaded if you'd like. Currently it's set to English (both en and en-US cause of set and auto-generated) as well as Japanese (I enjoy watching my fair share of Japanese content).

I have it use MP4 purely due to the support of the container in playback and modification platforms. I use --no-mtime to set the "Date Modified" to the date of download, as there's no need for upload date (since we've got two locations where it stores that data already). I've also chosen vtt as the subtitle file format as it's (I believe) the only one that is garunteed to be provided across all of Youtube (aside from when a video just doesn't have ANY subtitles available).

If you'd like to change them to something else, you'll need to look for the language codes for a video. Use the following command to do as such, then put them into the config (you can use one command and list the arguments/codes separated by commas, but I find splitting the commands up, like shown in my config, to be neater and easier to quickly change if needed).

By default, every command you run will attempt to download a video unless a certain command explicitly denies it, so in case, you can use the following within your config to disable downloading the video (at least temporarily).

Finally, I've put data about the video in both the metadata.json file (so, if you use Plex or Jellyfin to watch local Youtube videos, you can use those to sort, give names, etc.) as well as in a meta_comment section of the video file (via commands below) that isn't actually accessible through VLC (my favorite video viewing software). But, nonetheless, it is still another way to tie the original URL and original Upload Date to the video file itself.

I've added the following line to ignore Super Resolution as the highest priority resolution to download. If you don't know what Super Resolution is, Youtube has been using AI to upscale older videos that don't have 1080p or higher, up to 1080p. This config will give you the original video resolution

If you ever lose a metadata.json file, you can use the following Python code (which uses ffprobe which is packaged with ffmpeg) to extract ALL metadata, look for comment and extract the URL and put it into a text file for ALL videos in a folder. Disclaimer: This bit of python code was AI Generated to save time and tired me from having to think. It is safe and functional. It's simple.