Skip to content

Instantly share code, notes, and snippets.

@aripalo
Last active January 30, 2019 13:22
Show Gist options
  • Save aripalo/0eebf0d7a0b07b26850661afc58b68f4 to your computer and use it in GitHub Desktop.
Save aripalo/0eebf0d7a0b07b26850661afc58b68f4 to your computer and use it in GitHub Desktop.
Download Youtube videos for offline use

Download Youtube videos for offline use

Uses wernight/docker-youtube-dl Docker image.

Usage

  1. Provide a newline (\n) separated list of Youtube video IDs (like M7XM597XO94) or URLs (like https://www.youtube.com/watch?v=M7XM597XO94) in a txt file.

  2. Allow execution for the script file:

    chmod +x download-youtube-videos.sh
  3. Pass in the path to the file for the script as an argument:

    ./download-youtube-videos.sh list.txt
  4. Wait

  5. Downloaded video files can be found from $PWD/downloads

  6. Profit?

#!/bin/sh
while IFS='' read -r line || [[ -n "$line" ]]; do
docker run --rm --user $UID:$GID -v $PWD/downloads:/downloads wernight/youtube-dl $line
done < "$1"
M7XM597XO94
Lh-kVC2r2AU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment