#!/bin/bash # youtube2mp3 # uses youtube_dl and ffmpeg to get just the mp3 from youtube videos # By Sebastián Castillo Builes# Use this as the community wants in other words obey GPL3+ # Check parameters if [[ $# != 2 ]]; then echo Usage\: $0 video_url outputfile echo Example\: $0 "\"http://www.youtube.com/watch?v=ewHLy8T2cpA\"" could_be_harder.mp3 exit 1 fi # Check dependencies YOUTUBEDL=$(which youtube-dl) FFMPEG=$(which ffmpeg) if ( ( ! [[ -x $YOUTUBEDL ]] ) || (! [[ -x $FFMPEG ]])); then echo Error\: You need to install youtube_dl and ffmpeg. exit 1 fi # Everything is ok, so let me see what the video is and where you wanna get the mp3. URL=$1 OUTPUT=$2 # Temp file to store the video, juste the seconds and nanoseconds in the fiel name to evade collitions. FLV=/tmp/$(date +%s%N).flv # OK now go 4 the video and check for errors. youtube-dl $URL -o $FLV if [[ $? == 0 ]]; then # No errors so suck the mp3 checking 4 errors 2. ffmpeg -i $FLV -acodec copy $OUTPUT if [[ $? == 0 ]]; then # Everything was OK yeah! echo echo DONE !! now you can listen to $OUTPUT \:\) exit 0 fi # Oops ffmpg echo echo It seems that you have problems with ffmpeg, try googling the error. exit 1 fi # Oops youtube_dl echo echo It seems that you have problems with youtube_dl, maybe is the network conection?, try googling the error. exit 1
Math, logic and romantic nonsense
Thursday, September 10, 2009
Youtube 2 mp3
Using youtube-dl and ffmpeg this is a simple script just to get an mp3 file from a youtube URL:
Etiquetas:
programming bash
Subscribe to:
Post Comments (Atom)
0 comentarios:
Post a Comment