Skip to content

Instantly share code, notes, and snippets.

@franklinjavier
Created April 24, 2015 13:08
Show Gist options
  • Select an option

  • Save franklinjavier/305a5cd46100c1fcb589 to your computer and use it in GitHub Desktop.

Select an option

Save franklinjavier/305a5cd46100c1fcb589 to your computer and use it in GitHub Desktop.
A very simple Bash script to download a YouTube video and extract the music file from it.
#!/bin/bash
address=$1
regex='v=(.*)'
if [[ $address =~ $regex ]]; then
video_id=${BASH_REMATCH[1]}
video_id=$(echo $video_id | cut -d'&' -f1)
video_title="$(youtube-dl --get-title $address)"
youtube-dl $address
echo "Starting FFMPEG for: " $video_id " *********\n\n\n\n\n"
ffmpeg -i $video_id.flv "$video_title".wav
echo "Starting LAME &&&&&&&&&\n\n\n\n\n"
lame "$video_title".wav "$video_title".mp3
rm $video_id.$ext "$video_title".wav
else
echo "Sorry but the system encountered a problem."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment