Last active
July 23, 2021 15:05
-
-
Save Nezteb/1b76470294ad7bdd9ca0 to your computer and use it in GitHub Desktop.
Downloads specified youtube videos as songs given text file.
This file contains hidden or 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 | |
# Download_Songs.sh | |
# By Noah Betzen (Nezteb) | |
# | |
# Requires youtube-dl: https://rg3.github.io/youtube-dl/ | |
# You can install youtube-dl via most package managers: | |
# brew install youtube-dl | |
# apt-get install youtube-dl | |
# | |
# Creates relative directory called "downloads" with downloaded songs in it | |
# | |
# Sample file: (two video URLs on own lines, songs.txt) | |
# https://www.youtube.com/watch?v=abcdefghijk | |
# https://www.youtube.com/watch?v=lmnopqrstuv | |
# | |
# Once downloaded, song URL is removed from file | |
[ "$#" -eq 1 ] || { echo >&2 "Requires single text file (with youtube links on each line) name as argument."; exit 1; } | |
command -v youtube-dl >/dev/null 2>&1 || { echo >&2 "Install youtube-dl first."; exit 1; } | |
if [ ! -d "downloads" ]; then | |
mkdir downloads | |
fi | |
while IFS='' read -r line || [[ -n "$line" ]]; do | |
youtube-dl -x --audio-format mp3 $line -o './downloads/%(title)s.%(ext)s' | |
grep -v "$line" $1 > temp | |
mv temp $1 | |
done < "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment