Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. youtube-mp3 () {
  2. # get mp3 from youtube video
  3. # Author: Sergio Luiz Araujo Silva
  4. # site: http://vivaotux.blogspot.com
  5. # mail: voyeg3r [gmail]
  6. # twititer: @voyeg3r
  7. # Instalation: put thins function in your ~/.bashrc
  8.  
  9.     # testing parameters
  10.     if [ $# -eq 0 ] ; then
  11.         echo -e '\n\tUSAGE: youtube-mp3 youtube-link\n'
  12.         return 0
  13.     fi
  14.  
  15.     # testing existence of programs
  16.     NEEDED_COMMANDS="youtube-dl ffmpeg"
  17.     missing_counter=0
  18.     for needed_command in $NEEDED_COMMANDS; do
  19.         if ! hash "$needed_command" >/dev/null 2>&1; then
  20.             printf "Command not found in PATH: %s\n" "$needed_command" >&2
  21.             ((missing_counter++))
  22.         fi
  23.     done
  24.     if ((missing_counter > 0)); then
  25.         sudo apt-get install -y $NEEDED_COMMANDS
  26.     fi
  27.  
  28.     # geting video and converting with ffmpeg
  29.     youtube-dl --restrict-filenames -x --audio-format=mp3 --audio-quality 320k  "${1}"
  30. }