Created
May 13, 2015 03:23
-
-
Save idiom/67251c34232d29ca5e33 to your computer and use it in GitHub Desktop.
Rip Audio from youtube vid
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 | |
# | |
# Simple bash script to rip music from a youtube vid. | |
# Originally from: http://www.linuxjournal.com/content/grabbing-your-music-youtube-do-it-your-wam | |
# | |
address=$1 | |
regex='v=(.*)' | |
if [[ $address =~ $regex ]]; then | |
echo "Parsing URL" | |
video_id=${BASH_REMATCH[1]} | |
video_id=$(echo $video_id | cut -d'&' -f1) | |
echo "Getting Title" | |
video_title="$(youtube-dl --get-title $address)" | |
echo "$video_title" | |
echo "Getting filename" | |
filename="$(youtube-dl --get-filename $address)" | |
echo "$filename" | |
youtube-dl $address | |
ext=$(echo $filename | cut -d \. -f 2) | |
avconv -i "$filename" "$video_title".wav | |
lame "$video_title".wav "$video_title".mp3 | |
rm "$filename" "$video_title".wav | |
else | |
echo "Error!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment