Skip to content

Instantly share code, notes, and snippets.

@kamladi
Last active November 23, 2019 12:53
Show Gist options
  • Save kamladi/5085043 to your computer and use it in GitHub Desktop.
Save kamladi/5085043 to your computer and use it in GitHub Desktop.
Youtube Video To MP3 File Bash Script (Mac OS X)
#! bin/bash
#PREREQ's: Install XCode Command Line Tools, Homebrew, and MacPorts
brew install wget lame #wget retrieves files via HTTP, lame is an MP3 encoder
sudo port install ffmpeg
sudo wget http://youtube-dl.org/downloads/2013.02.25/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl #make youtube-dl file executable
#make custom bash shortcut. Source: http://alias.sh/youtube-video-mp3-file
echo "mp3(){ youtube-dl $1 --extract-audio --title --audio-format mp3 }" >> ~/.bash_profile
source ~/.bash_profile
echo "Setup complete! To download, run 'mp3 {link}', where {link} is the YouTube Link"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment