how to wget flv from youtube

August 1st, 2007 mysurface Posted in Network, wget | Hits: 143966 | 44 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

Step one, download it and extract the encrypted strings using grep.

wget -O test

-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 and start download.

wget -O test.flv ""

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, 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

44 Responses to “how to wget flv from youtube”

  1. [...] 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 » [...]

  2. Probably the easiest way to download youtube vid is using youtube downloader from with ffmpeg patch for avi conversion.

    # youtube-dl -a -o my.avi\?v=B6fnR–IDKc

    Anyway, nice tutorial on downloading flv with the use of scripting language.

  3. chfl4gs_:
    I tried that before, if my memory servers me right, it was written by python. That is cool.

  4. ドラマ見るならここ!DORAMA.COM…


  5. 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–IDKc
    *) yturl=$1;;
    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”\

  6. Where is encrypted string here ?
    uros@SvarogBg:~$ grep “player2.swf” rusia
    var swfUrl = ‘/player2.swf?v=1′;

    v=1 ? Do I missed something ?

  7. Uros:
    Due to the changes youtube have made, grep “player2.swf” no longer valid.

    try grep “fullscreen”

    grep "fullscreen" test -m1 | cut -d'?' -f2 | cut -d'"' -f1
  8. 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 “$ID”

  9. 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.

  10. 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.

  11. 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 :)

  12. Here is a Bash script which only uses bash and wget to download the youtube video.

  13. today announces YouTube Robot 2.0, a tool that enables you to download video from 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
    Direct download link: ww
    Company web-site: w

  14. Your script (posted on comment #comment-24692) works perfectly.

    I would just add the -c parameter to wget, for unstable connections mostly.

    Thanks ;)

  15. Youtube videos are now loaded in /tmp
    Just wait for Flash to load it fully, and rename it =]

  16. 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–
    Resolving,,, …
    Connecting to||: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.

  17. any updates? thanks. web development

  18. i could download youtube videos using youtube-dl web development philippines

  19. 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!

  20. Doesn’t work anymore!!

  21. it doesn’t work anymore this method

  22. Thanks for every other great article. Where else may anyone get that kind of information in such
    an ideal manner of writing? I have a presentation next
    week, and I’m at the look for such info.

  23. If you would like to obtain a good deal from
    this post then you have to apply these methods to your won webpage.

  24. Normally I do not read post on blogs, however I wish to say that
    this write-up very forced me to try and do so! Your writing taste has been
    amazed me. Thank you, quite nice post.

  25. For the reason that the admin of this site is
    working, no hesitation very soon it will be well-known, due to its quality contents.

  26. Your style is very unique compared to other people I’ve read stuff from. Thanks for posting when you’ve got the opportunity, Guess I will just
    book mark this page.

  27. Scott F said:Rather than innovate their way out spakujmy najlepiej w twardych skrzynkach czy szufladach.\r\n\r\n\r\n\r\nWszystkie gatunki art agd i rtv powinny by? zapakowane \r\n\r\nw oryginalne opakowanie| je?eli kiedy je posiadamy| w przeciwnym wypadku zawin?? w koce \r\n\r\norazzabezpieczy?|zafoliowa?} foli? b?belkow? oraz foli? typu strecz je?li to mo?liwe.Wówczas przeprowadzka tego mienia oraz transport owego sprz?tu \r\n\r\njest tylko i wy??cznie na odpowiedzialno?? w?a?ciciela .\r\n\r\n\r\n\r\nWszystkie ro?liny musz? wyl?dowa? w kontenerkach.Je?eli \r\n\r\nz?oto| oszcz?dno?ci i osobiste dokumenty s? pakowane oddzielnie i transportowane przez klienta osobi?cie do swojego domu\r\n\r\n.Planuj?c przeprowadzki pozna? wybierz czas poza szczytami \r\n\r\nwtedy sprawniej potrwa przejazd.Wszystko co powinno by? dost?pne bezpo?rednio \r\n\r\npo przybyciu do nowego mieszkanianp: jak art.higieniczne| spanie| ubrania|?ywno??| itp.\r\n\r\nmusz? by? pakowane osobno aby szybko je znale??\r\n\r\nRzeczy| takie jak ?atwopalne| toksyczne| |kwasowe itp.\r\n\r\nnie s? dozwolone.\r\n\r\nArtyku?y spo?ywcze|Spo?ywka|Jedzenie} w ostatnim dniu.Warto {posegregowa?|uprz?tn??| prowiant| które straci?y swoj? warto?? czy termin spo?ycia|{reszt?|pozosta?o?? zapakowa? w plastikowe torby przed \r\n\r\nzapakowaniem w skrzynkach.\r\n\r\nMeble-pó?ki powinny by? od??czone ile si? da i zabezpieczy? ostre boki (np.\r\n\r\nSzafy| pó?ki i przek?adki). Miej tak?e na uwadze| aby zebra? wszystkie materia?y + sprz?t do przeprowadzki pozna? .\r\n\r\nNa miejscu mo?liwe b?dzie natychmiast Unfortunately

  28. I quite like reading an article that will make people
    think. Also, many thanks for allowing for me to comment!

    Feel free to visit my site :: renovate kitchen

  29. Thanks to my father who shared with me about this blog, this weblog is in fact remarkable.

    My site: country kitchen designs

  30. Can I simply say what a relief to find a person that genuinely understands what they are discussing
    on the net. You definitely realize how to bring a problem to light and
    make it important. More and more people need to look at this and understand this side of the story.
    It’s surprising you’re not more popular because you certainly have the gift.

    my weblog – Kitchen Backsplash Idea

  31. I must thank you for the efforts you’ve put in writing this
    website. I’m hoping to view the same high-grade
    content from you in the future as well. In fact, your creative writing abilities
    has inspired me to get my own website now ;)

    My homepage … all in one kitchen

  32. Ahaa, its good discussion about this article at this place at
    this website, I have read all that, so now me also commenting at this place.

  33. Hello There. I found your blog using msn. This is a really well written article.
    I’ll be sure to bookmark it and return to read more of your
    useful info. Thanks for the post. I will certainly comeback.

  34. ” Proceeds from the song’s product sales will benefit the charity Women’s Aid, which allows ladies and kids who have been victims of abuse. Asda a subsidiary of Wal-Mart which has GMO free rules, and they will turn into Hershey’s unique retailer in the United Kingdom. Mel Defelice, owner of Coco Boo boutique in Cannon Street agreed that numerous of the clothes she sells to youthful customers are shorter – and they also like to gown up to go out.

    My page: ASDA Direct

  35. With havin so much content and articles do you ever run into any issues of plagorism or copyright violation?
    My site has a lot of completely unique content I’ve either
    written myself or outsourced but it appears a lot of
    it is popping it up all over the internet without my
    permission. Do you know any ways to help protect
    against content from being ripped off? I’d certainly
    appreciate it.

  36. Décompressez Equideow pirater equus passe gratuit et commencer à tricher.

  37. Undeniably imagine that which you stated. Your favorite reason seemed to be on the web the simplest factor to keep in mind of.
    I say to you, I definitely get irked while other people
    consider issues that they plainly do not recognize about.

    You controlled to hit the nail upon the top as well as defined out the entire thing with no need side-effects
    , other people can take a signal. Will likely
    be again to get more. Thanks

  38. I am really enjoying the theme/design of your web site.
    Do you ever run into any web browser compatibility problems?
    A handful of my blog readers have complained about my site not working correctly in Explorer but looks great in Chrome.

    Do you have any recommendations to help fix this problem?

  39. This is the perfect webpage for anybody who wishes to find
    out about this topic. You understand so much its almost tough to argue with you (not that I really would want to…HaHa).
    You certainly put a fresh spin on a subject that has been written about for ages.
    Excellent stuff, just excellent!

  40. Appreciating the hard work you put into your site and in depth information you provide.
    It’s nice to come across a blog every once in a while that
    isn’t the same out of date rehashed information. Fantastic read!
    I’ve saved your site and I’m including your RSS feeds to my Google account.

  41. Awesome issues here. I’m very satisfied to see your
    post. Thank you a lot and I am taking a look forward to contact you.

    Will you kindly drop me a e-mail?

  42. When one account goes down, open another and re-up.
    Let me just recommend to you the things that I am doing so far.

    Read more about hostgator coupon at hostgatorcouponandreview.

  43. We have been a variety of volunteers and opening up a fresh program in the area. Your web site supplied people having valuable data for you to works of art in. You have completed your powerful employment along with the full team will likely be thankful to your account.. Schlagzeug lernen Münster MOTET

Leave a Reply