Skip to content

Instantly share code, notes, and snippets.

@w0rp
Created December 12, 2018 13:15
Show Gist options
  • Save w0rp/3e8dfe8a2b49af8083ede828b0e24c16 to your computer and use it in GitHub Desktop.
Save w0rp/3e8dfe8a2b49af8083ede828b0e24c16 to your computer and use it in GitHub Desktop.
Backup YouTube channels
#!/bin/bash
# Change to the directory for this script.
cd "$(dirname "$(realpath "$0")")"
if ! [ -d ve ]; then
python3 -m venv ve
fi
ve/bin/pip install -q -U youtube-dl
# This one liner, with comments, will archive YouTube channels for you.
# You have to list channel links, line-by-line in download.list
# Completed video downloads will be saved to complete.list.
# You can run this in cron every night.
# -q does things quietly.
# -a <file> is list of things to grab.
# For a list of users use 'ytuser:<usename>' for each line.
# -f bestvideo+bestaudio/best gets you the best stuff. You need ffmpeg.
# --download-archive <filename> names a file to save completed downloads in.
# --write-info-json --write-thumbnail --add-metadata will preserve as much
# information about a video as possible, except subtitles and comments.
# the -o format specifies where to output files and with what names.
ve/bin/youtube-dl \
-q \
-a ./download.list \
-f 'bestvideo[ext!=webm]+bestaudio[ext!=webm]/best[ext!=webm]' \
--no-warnings \
--ignore-errors \
--download-archive ./complete.list \
--write-info-json --write-thumbnail --add-metadata \
-o "./video/%(uploader)s/%(title)s {%(id)s}.%(ext)s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment