how to wget flv from youtube
August 1st, 2007 mysurface Posted in Network, wget | Hits: 92925 | 22 Comments »
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
http://www.youtube.com/watch?v=B6fnR--IDKc
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 “
hl=en&video_id=B6fnR--IDKc&l=34&t=OEgsToPDskIlg4F-gKjbwl_pqIP6IPeI&soff=1&sk=V7GrH18hYLfT0sz5dm7GXgC
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:
dltube.sh http://www.youtube.com/watch?v=B6fnR--IDKc
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







August 1st, 2007 at 2:55 am
[...] Yahoo Contact the Webmaster Link to Article youtube how to wget flv from youtube » Posted at Linux By Examples – We explain every GNU/Linux command line by examples on Tuesday, July 31, 2007 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 … (first output file from youtube link shows above). grep “id=”video_title”" test The output View Original Article » [...]
August 1st, 2007 at 1:23 pm
Probably the easiest way to download youtube vid is using youtube downloader from http://www.arrakis.es/~rggi3/youtube-dl with ffmpeg patch for avi conversion.
# youtube-dl -a -o my.avi http://www.youtube.com/watch\?v=B6fnR–IDKc
Anyway, nice tutorial on downloading flv with the use of scripting language.
August 1st, 2007 at 11:07 pm
chfl4gs_:
I tried that before, if my memory servers me right, it was written by python. That is cool.
August 2nd, 2007 at 5:56 pm
ドラマ見るãªã‚‰ã“ã“ï¼DORAMA.COM…
æ€ã„出ã®ãƒ‰ãƒ©ãƒžã‚„見逃ã—ã¦ã—ã¾ã£ãŸãƒ‰ãƒ©ãƒžãªã©ãƒ‰ãƒ©ãƒžã‚’一挙公開ä¸ï¼ï¼…
August 9th, 2007 at 5:48 pm
Here is my version of the script:
(it is a bash function that doesnt write temporary files)
function ytdl {
local yturl ythtml encurl flvtitle flvurl
while [[ -n $1 ]]; do
case $1 in
“-r”) raw_name=true;;
# for example http://www.youtube.com/watch?v=B6fnR–IDKc
*) yturl=$1;;
esac
shift
done
ythtml=$(wget -O – “$yturl” 2>/dev/null)
encurl=$(echo “$ythtml” | grep -o -E ‘player2\.swf?[^\"]+’ |
head -n 1 | sed ‘s/^player2\.swf?//g’)
flvtitle=$(echo “$ythtml” | grep ‘id=\”video_title\”‘ |
cut -d”>” -f2 | cut -d”\
September 17th, 2007 at 8:03 pm
Where is encrypted string here ?
uros@SvarogBg:~$ grep “player2.swf” rusia
var swfUrl = ‘/player2.swf?v=1′;
v=1 ? Do I missed something ?
September 20th, 2007 at 12:46 am
Uros:
Due to the changes youtube have made, grep “player2.swf” no longer valid.
try grep “fullscreen”
December 15th, 2007 at 6:27 pm
Quick and dirty version. Names the file after the title of the video (minus spaces and special characters).
RAW=`wget -O – $1 | grep ‘fullscreenUrl’ | sed ‘s/^.*video_id=//’`
TITLE=`echo $RAW | sed ‘s/^.*title=//’ | sed ‘s/[^a-zA-Z0-9]//g’`
ID=`echo $RAW |sed ‘s/&fs.*$//’`
wget -O $TITLE.flv “http://www.youtube.com/get_video.php?hl=en&video_id=$ID”
December 26th, 2007 at 8:10 am
it seems youtube have changed it yet again!
now the only fields in the get request should be
‘video_id’ and ‘t’ (‘sk’ and ‘l’ don’t seem to be used… )
I’m not posting my code in the hope that fewer people do this and youtube takes longer to change it again…
using a user-agent overrride in the wget calls may help avoid detection too.
December 28th, 2007 at 8:21 pm
So utube has again changed. This script is not working any more :-( what will be the changes or the modification required in the script then ?
thanks for the nice script.
January 17th, 2008 at 7:35 am
http://www.FreeYoutubeGrabber.com is another online tool to download videos from Youtube. You enter the url of youtube video and press “Grab and download” button, then choose a directory where to save, and download the video :)
January 25th, 2008 at 7:02 pm
Here is a Bash script which only uses bash and wget to download the youtube video.
http://www.xinilux.us/misc/index.html#hoovertube
June 10th, 2008 at 3:40 pm
YouTubeRobot.com today announces YouTube Robot 2.0, a tool that enables you to download video from YouTube.com onto your PC, convert it to various formats to watch it when you are on the road on mobile devices like mobile phone, iPod, iPhone, Pocket PC, PSP, or Zune.
YouTube Robot allows you to search for videos using keywords or browse video by category, author, channel, language, tags, etc. When you find something noteworthy, you can preview the video right in YouTube Robot and then download it onto the hard disk drive. The speed, at which you will be downloading, is very high: up to 5 times faster than other software when you download a single file and up to 4 times faster when you download multiple files at a time.
Manual download is not the only option with YouTube Robot. You may as well schedule the download and conversion tasks to be executed automatically, even when you are not around. Downloading is followed by conversion to the format of your choice and uploading videos to a mobile device (if needed). For example, you can plug in iPod, select the video, go to bed, and when you wake up next morning, your iPod will be ready to play new YouTube videos.
Product page: ww w.youtuberobot.com
Direct download link: ww w.youtuberobot.com/download/utuberobot.exe
Company web-site: w ww.youtuberobot.com
January 21st, 2009 at 2:10 am
Your script (posted on comment #comment-24692) works perfectly.
I would just add the -c parameter to wget, for unstable connections mostly.
Thanks ;)
May 13th, 2009 at 9:21 pm
Something for Pythonists Howto Get Direct YouTube Video (FLV) URL
September 15th, 2009 at 10:26 pm
Youtube videos are now loaded in /tmp
Just wait for Flash to load it fully, and rename it =]
January 31st, 2010 at 11:53 pm
after runing “grep “fullscreen” test -m1 | cut -d’?’ -f2 | cut -d’”‘ -f1″
I encounter the following in my Test file :
–2010-01-31 18:55:21– http://www.youtube.com/watch?v=kPQR-OsH0RQ
Resolving http://www.youtube.com... 216.239.59.101, 216.239.59.113, 216.239.59.102, …
Connecting to http://www.youtube.com|216.239.59.101|:80… connected.
HTTP request sent, awaiting response… 403 Forbidden
2010-01-31 18:55:22 ERROR 403: Forbidden.
what is the problem?
ps:I use Tor software for bypassing filters in Iran.
May 1st, 2010 at 1:41 pm
any updates? thanks. web development
May 15th, 2010 at 1:23 pm
i could download youtube videos using youtube-dl web development philippines
April 26th, 2011 at 11:14 am
Hi there, just found this page from digg. It is not blog post I would regularly read, but I loved your spin on it. Thanx for making a piece worth reading!
September 13th, 2011 at 3:35 pm
Doesn’t work anymore!!
November 19th, 2011 at 10:47 pm
it doesn’t work anymore this method