Mittwoch, 22. April 2009

Download youtube videos (and whole chanels) from the terminal

Because I need some video tutorials, which I prefer to watch off-line (in the train for instance), I prog'd a Shell-Script (for linux terminal) to do the work for me.

1. y2flv.sh

#!/bin/bash
echo "::Try to get $1"
wget -q -O tmp.tmp "$1"
wget -O "`cat tmp.tmp | grep video_id= | grep fullscreen | egrep "title=(.*)" -o | egrep "[^=]*$" -o | egrep "^[^\']*" -o`.flv" http://www.youtube.com/get_video`cat tmp.tmp | grep video_id= | grep watch_fullscreen | egrep "\?(.*)" -o`
rm tmp.tmp
Usage (after chmod u+x y2flv.sh):
$ y2flv.sh http://www.youtube.com/watch?....

2. Complete Channel Download:

#!/bin/bash
wget -nv -O tmp2.tmp "$1"
for i in `cat tmp2.tmp | grep watch? | egrep "href=\"[^\"]+\"" -o | grep watch? | grep channel | egrep "[^(href=\"\/)].+[^\"]" -o | sort | uniq`
do
echo $i
./y2flv.sh "http://www.youtube.com/$i"
done
rm tmp2.tm

have fun with these ;)

PS: Converting a flv to mp3 (after apt-get install ffmpeg)
ffmpeg -i in.flv -acodec copy out.mp3

Keine Kommentare:

Kommentar veröffentlichen