youtube2mp3
Simple Shell Script to download Youtube Videos and convert them on the fly to mp3 files.
Install Dependencies
via Homebrew
brew install youtube-dl ffmpeg libav
or
from Source
With the dependencies installed your ready to go.
Download the Script ydl.sh and make it executable chmod u+x ydl.sh
Run the Script via:
./ydl.sh url
url can be a youtube link, playlist, channel ...
By default the mp3 files are stored in the same folder where the script was executed.
You can create an alias to run the script from everywhere: alias ydl="/src/to/file/ydl.sh"
Thats it happy downloading!
Source
#!/usr/bin/env bash
#
# /$$$$$$$$ /$$$$$$ /$$
# | $$_____/ /$$__ $$ | $$
# | $$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ | $$ \__//$$$$$$
# | $$$$$ /$$__ $$|____ $$ /$$__ $$ /$$_____/ /$$__ $$| $$$$ |_ $$_/
# | $$__/| $$ \__/ /$$$$$$$| $$ \ $$| $$$$$$ | $$ \ $$| $$_/ | $$
# | $$ | $$ /$$__ $$| $$ | $$ \____ $$| $$ | $$| $$ | $$ /$$
# | $$ | $$ | $$$$$$$| $$$$$$$/ /$$$$$$$/| $$$$$$/| $$ | $$$$/
# |__/ |__/ \_______/| $$____/ |_______/ \______/ |__/ \___/
# | $$
# | $$
# |__/
#
# Developer Maik Ellerbrock
# GitHub https://github.com/ellerbrock
# Twitter https://twitter.com/frapsoft
# Facebook https://facebook.com/frapsoft
#
# Version 1.1.0
#
# Dependencies: brew install youtube-dl ffmpeg libav
#
# CONFIGURATION
BASEDIR="/Volumes/Media/Music"
MP3DIR="$BASEDIR/youtube/"
LOGFILE="$BASEDIR/youtube.log"
DATE=`date +%Y-%m-%d`
if [ ! "$1" ]; then
echo "usage: ydl.sh youtube-url"
exit 1
fi
cd $MP3DIR
echo -e "$DATE \t $1" >> $LOGFILE
youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 --ignore-errors $@
if [ `uname` == "Darwin" ] ; then
osascript -e 'display notification "All Downloads done." with title "Youtube Downloader"'
open .
fi
Contact / Social Media
Get the latest News about Web Development, Open Source, Tooling, Server & Security
Development by
Developer / Author: Maik Ellerbrock
Company: Frapsoft
License
Copyright (c) 2016 Maik Ellerbrock