Created
October 15, 2017 21:38
-
-
Save mentos1386/909906bde0f92959f0b63c591c2303ab to your computer and use it in GitHub Desktop.
Download Youtube playlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prameters | |
PLAYLIST_ID=$1; | |
TYPE=$2; | |
# Constants | |
FOLDER="$HOME/Youtube"; | |
PROGRAM_DATA="$(pwd)/yt-playlist-downloader" | |
# Verify that type is provided | |
if [[ $TYPE != 'video' && $TYPE != 'audio' ]]; then | |
echo "Invalid type! Should be 'video' or 'audio'" | |
exit 1 | |
fi | |
if [ ! -d $PROGRAM_DATA ]; then | |
mkdir -p "$PROGRAM_DATA" | |
fi | |
# Download video | |
if [ $TYPE = 'video' ]; then | |
youtube-dl \ | |
-o "$FOLDER/%(playlist)s/%(playlist_index)s-%(title)s/%(title)s.%(ext)s" \ | |
-i \ | |
--write-description \ | |
--write-info-json \ | |
--write-thumbnail \ | |
--write-sub \ | |
--embed-thumbnail \ | |
--embed-subs \ | |
--prefer-free-formats \ | |
--download-archive "$PROGRAM_DATA/progress-$PLAYLIST_ID.txt" \ | |
"http://www.youtube.com/playlist?list=$PLAYLIST_ID" | |
fi | |
# Download audio | |
if [ $TYPE = 'audio' ]; then | |
youtube-dl \ | |
-o "$FOLDER/%(playlist)s/%(playlist_index)s %(title)s.%(ext)s" \ | |
-i \ | |
--extract-audio \ | |
--embed-thumbnail \ | |
--audio-format mp3 \ | |
--download-archive "$PROGRAM_DATA/progress-$PLAYLIST_ID.txt" \ | |
"http://www.youtube.com/playlist?list=$PLAYLIST_ID" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment