youtube-dl-agent

Januar 22nd, 2011 § 3 comments § permalink

youtube-dl-agent laedt eine liste von youtube-videos mit youtube-dl runter, konvertiert sie mit ffmpeg und fuegt sie mit mencoder zusammen. gedacht fuer splited youtube-videos.

usage:

$ youtube-dl-agent http://www.youtube.com/watch?v=Qpwj5k0zYDs \
http://www.youtube.com/watch?v=XCyXY4jLxo8 \
http://www.youtube.com/watch?v=BwJUV8vvGyA \
http://www.youtube.com/watch?v=xQuyiMravE4 \
--output="Weimar nach der Wende.avi"
#!/bin/bash

case "$1" in

  "" )
      exit $E_PARAM ;
  ;;

  * )
    TEMPPATH=$PWD"/youtube-dl-agent.swap/";
    mkdir $TEMPPATH;
    cd $TEMPPATH;

    for i in "$@"
    do
      case "$i" in
        http://* )
            URL=`echo $i`;
            echo " * * * "$URL" * * *";

            ###
            # DOWNLOAD FLV WITH YOUTUBE-DL
            /usr/local/bin/youtube-dl -t $URL

            ###
            # FIND DOWNLOADED FLV FILE BY ID
            ID=`echo $URL | /bin/sed -r 's/.*v=(.*)$/\1/'`;
#            echo $ID;
            IDS=$IDS$ID" ";

            FLV=`/usr/bin/find $PWD"/" -maxdepth 1 -name "*$ID.flv"`;
#            echo $FLV;
            FLVS=$FLVS$FLV" ";

            ###
            # COVERT FLV TO AVI
            /usr/bin/ffmpeg -i $FLV -vcodec copy \
            -acodec libmp3lame -ab 128k $FLV".avi"

            AVI=`/usr/bin/find $PWD"/" -maxdepth 1 \
            -name "*$ID*.avi"`;
#            echo $AVI
            AVIS=$AVIS$AVI" ";
        ;;

        # STRINGS WITH WHITESPACES HAVE TO BE
        # ENCAPSULATE WITH DOUBLE QUOTES
        --output=* )
            OUTPUT=`echo $i | sed 's/--output=//'`;
        ;;

        * )
            exit $E_PARAM ;
        ;;

      esac
    done
  ;;

esac

###
# MERGE SPLIT AVIS
/usr/bin/mencoder -ovc copy -oac copy $AVIS -o $OUTPUT

###
# MOVE FROM TEMP-DIR TO $USERS PWD
/bin/mv -v $OUTPUT ..

###
# CLEAN UP
/bin/rm -rv $TEMPPATH

exit 0

Where Am I?

You are currently browsing entries tagged with mencoder at maschinenraum.