how to wget flv from youtube

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

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

  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 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”\

  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 “http://www.youtube.com/get_video.php?hl=en&video_id=$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. 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 :)

  12. Here is a Bash script which only uses bash and wget to download the youtube video.
    http://www.xinilux.us/misc/index.html#hoovertube

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

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

  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

  44. Marcus Rashford has been named as a part of England’s provisional squad for Euro 2016
    with the inclusion of the uncapped striker finishing one of the recreation’s best rises.

  45. Structure myth that will he or she is contributing to the top cases of divorce charge, based on them reviews portion more of the most important ruined unions of your my best mate enquiries Geige lernen online – Geige lernen Münster – Geige lernen in Münster Geige Münster one of the most wedding rehearsal

  46. Having read this I thought it was very enlightening. I appreciate you taking the
    time and energy to put this article together.
    I once again find myself personally spending a lot of time both
    reading and posting comments. But so what, it was still worthwhile!

  47. Nonetheless, specific homebuyers are excellent prospects
    for this kind of home loan, consisting of those
    fha lenders in dallas tx – Shelton, the process of reestablishing their credit
    rating as well as applicants with a. short credit rating.

  48. He wound up being able to obtain a 15-year home loan at 3.65 % for his first home from Churchill Home mortgage, which
    supplies a no score loan product by taking non-traditional credit lines and
    adding them to Pittman’s credit report.

    My blog – fha loans dallas tx [Erik]

  49. fha loans near me – Raina – home loan limits in Wisconsin, Illinois, Minnesota as well as Florida could
    be downloaded below.

  50. The basic fha loans lewisville tx (Owen) mortgage insurance program is Home
    loan Insurance coverage for One-to-Four-Family Residence (Part
    203(b)).

  51. fha loans dallas tx, Lamar, debtors have to likewise understand that reasonably tiny declines in house worths can cause some to be ‘underwater’ on their
    mortgage with low equity financial investments in the
    property,” Cahoon claimed.

  52. fha loan near me (http://www.xmarks.com) intends to
    make certain that 41 % to 43 % of your monthly gross earnings could
    be applied to making the minimum settlements on all of your month-to-month financial
    obligations, consisting of rotating charges and installment financings,
    claimed Scott Smith, head of state of, a Salt Lake City-based credit rating repair work firm.

  53. The industry for FHA financings is gigantic, which develops affordable stress among loan providers to
    offer reduced fha loans dallas tx (Wilfredo) prices as well as reduced FHA charges.

  54. If you satisfy these demands, you could get approved for an fha loans lewisville tx (Debbie) loan, which allows you to put down as little bit as 3.5 % on a home loan.

  55. Initially, the apartment building must be authorized by fort worth fha loans (Genia) (FHA authorized condo checklist ).
    This merely indicates that certain records have actually been completed as well as signed off by FHA.

  56. Typically a 620 center score is needed to be considered
    for a best fha mortgage lenders lending (3.5 %
    down plus closing price’s ). Read all you can under credit scores on this site.

  57. Obtaining accepted for an fha loans dallas tx home mortgage is partially dependent on the customer’s
    yearly revenue.

  58. When requesting a mortgage loan, the fha loan limits dallas county [Benedict] provider assesses your gross monthly earnings
    to establish just how much you can pay for to invest – real estate ratio” refers to the percent of your gross earnings that you can spend on your home mortgage settlement.

  59. Enjoying the information on this website, you have done an outstanding job on the
    content.

    my blog Claribel

  60. Do you mind if I quote a couple of your articles as long as I provide credit
    and sources back to your blog? My blog is in the very same area of
    interest as yours and my visitors would definitely benefit from some of
    the information you present here. Please let me
    know if this ok with you. Regards!

  61. Amazing blog! Do you have any suggestions for aspiring writers?
    I’m planning to start my own site soon but I’m a little lost on everything.
    Would you recommend starting with a free platform like WordPress
    or go for a paid option? There are so many choices out there that I’m completely confused ..

    Any ideas? Kudos!

  62. Thumbs up for a Good

  63. Marvelous, what a webpage it is! This blog gives useful data
    to us, keep it up.

  64. What’s up, I wish for to subscribe for this blog to obtain most recent updates, therefore where can i do it please help.

  65. Thankfulness to my father who told me concerning this webpage, this weblog
    is genuinely amazing.

  66. I would like to thank you for the efforts you’ve put in writing this website.

    I am hoping to see the same high-grade blog posts by you in the future as well.
    In fact, your creative writing abilities has inspired
    me to get my own, personal blog now ;)

Leave a Reply