Samstag, 20. April 2013

YouTube videos to mp3 converter script

I am using a tiny shell script that converts a youtube video to mp3. It takes as input the youtube url and generates the mp3 in ~/youtube-dl. It requires youtube-dl, so probably it is limited to *NIX boxes.
$ sudo apt-get install youtube-dl
Create a file youtube-conv.sh with the following code
#/bin/sh name=$(youtube-dl --get-title ${1}|sed 's/ /_/g') echo title ${name} id=$(echo ${1} | sed 's/=/ /g' | awk '{print $2}') echo download to ${id} youtube-dl ${1} -o ${id} # > /dev/null echo convert to ~/youtube-dl/${name}.mp3 convert=$(ffmpeg -i ${id} -f mp3 ~/youtube-dl/${name}.mp3) echo ${name}.mp3 created echo remove ${id} rm ${id}
Invoke the script with the youtube url as argument, e.g.
./youtube-conv.sh http://www.youtube.com/watch?v=7cF2ZSNrEIw
Note: there are issues, if the video name contains non ASCII characters

Keine Kommentare:

Kommentar veröffentlichen