Code Dump: channeldown.sh

Building on youtube.sh, this downloads an entire youtube channel. Usefull for marathon viewing sessions.

#!/bin/bash if [ "x$1" = "x" ] then echo channeldown "(username)" exit fi if [ ! "x$2" = "x" ] then MAX=$2 else MAX=100 fi USER=$1 i=1 while [ $i -lt "$MAX" ] do wget http://gdata.youtube.com/feeds/api/users/$USER/uploads\?start-index="$i"\&max-results=50 -O $USER.$i.raw let "i+=50" done #results=($(cat $USER*raw | sed 's/.*\(http:\/\/www.youtube.com\/watch?v=.\{11\}\).*/\1/g;/^http/!s/.*//g;/watch/!s/.*//g' | sort | uniq)) results=($(cat $USER*raw | sed 's/http/\nhttp/g' | grep 'api/videos' | sed 's/.*videos\///g;s/[<\/].*//g'|sort | uniq)) echo $results mkdir /downloads/watch/misc/$USER for X in ${results[@]} do X="http://youtube.com/watch?v=$X" echo $X >> $USER.log youtube-dl -o "/downloads/watch/misc/$USER/%(upload_date)s.%(stitle)s.%(ext)s" "$X" done rm $USER*raw

Code Dump: youtube.sh

Downloads youtube videos using youtube-dl. I built it to download multiple videos in a row. Put each url in a pair of single quotes.

“`bash
#!/bin/bash SETDIR=”/downloads/watch/misc” DIRFLAG=0 for ARG in $* do ARG=”$(echo “$ARG” | sed ‘s/feature=[a-z_+]*&//’)” # http://www.youtube.com/watch?feature=player_embedded&v=qeK0KmtYNaA # http://www.youtube.com/watch?v=kV832rfjcas&feature=related echo “$ARG” if [ x$ARG = x ] then exit elif [ x$ARG = “x-d” ] then DIRFLAG=1 elif [ $DIRFLAG = 1 ] then DIRFLAG=0 SETDIR=$ARG else echo “$SETDIR $ARG” youtube-dl -w -o “$SETDIR/%(title)s.%(ext)s” –max-quality=22 “$ARG” fi done
“`