Created
August 15, 2016 21:49
-
-
Save go-ive/1322365f4c459f371e054864f60dd5b3 to your computer and use it in GitHub Desktop.
YouTube DL + ffmpeg mp3 downloader script
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 | |
readonly TMP_DIR="/tmp/ytdl" | |
readonly TMP_OUT="/tmp/out" | |
readonly ARGS="$@" | |
download_video() { | |
echo "================================ Downloading $1 ================================" | |
youtube-dl $1 --output ${TMP_DIR}/%\(title\)s | |
} | |
delete_tmp() { | |
rm -rf ${TMP_DIR} | |
} | |
convert(){ | |
ffmpeg -i "${TMP_DIR}/${1}" -acodec libmp3lame -ab 128k "${TMP_OUT}/${1}.mp3" | |
} | |
get_filename(){ | |
ls ${TMP_DIR} | |
} | |
main() { | |
mkdir -p ${TMP_OUT} | |
while read url | |
do | |
download_video $url | |
convert "$(get_filename)" | |
delete_tmp | |
done < ${ARGS[0]} | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment