To strip flv from youtube links, you have to complete two steps. Firstly extract the encrypted string from a youtube link, next append to get_video.php and download through wget.
The youtube links, that people distribute around will looks something like below
Step one, download it and extract the encrypted strings using grep.
wget -O test http://www.youtube.com/watch?v=B6fnR--IDKc
-O is to force the output filename as specified. The case above, output filename will be ‘test’.
To extract the encrypted string, use grep
grep "player2.swf" test
Updates! Due to the changes of youtube, the grep shown above was no longer working, grep “fullscreen” instead, read the comment for more details.
The encrypted string will be in between player2.swf? and “
Step two, append the string to http://www.youtube.com/get_video.php? and start download.
wget -O test.flv "http://www.youtube.com/get_video.php?hl=en&video_id=B6fnR--IDKc&l=34&t=OEgsToPDskIlg4F-gKjbwl_pqIP6IPeI&soff=1&sk=V7GrH18hYLfT0sz5dm7GXgC"
Too much manual works?
You can write a bash script to ease your download, turn all manual steps into one simple step. Let say the script is know as dltube.sh, you just need to execute this:
You will get the output filename as the_title_of_the_youtube.flv.
There are some hints , in case you are interested on creating this bash script.
1. The title of the flv, you can grep it from ‘test’ (first output file from youtube link shows above).
grep "id=\"video_title\"" test
The output will be
<h1 id="video_title">xvidcap screen capture on mplayer</h1>
2. You can extract the title from the grep string using cut.
grep "id=\"video_title\"" test | cut -d">" -f2 | cut -d"<" -f1
Check out command cut for usage examples.
Enjoy your bash scripting :D