Downloading all related videos from youtube with youtube-dl

2010-05-16 2 min read Fedora Learning Linux Uncategorized

How many time did you want to see all the videos (related) to the one you were watching on youtube but decided otherwise as the downloaded was not fast enough. Or has it happened to you that you wanted to <a class="zem_slink freebase/en/uploading_and_downloading" title="Uploading and downloading" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uploading_and_downloading">download all the related videos, in either case you can use the youtube-dl utility I blogged about some times back. First you need to get all the <a class="zem_slink freebase/en/uniform_resource_locator" title="Uniform Resource Locator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL&#8217;s in a <a class="zem_slink freebase/en/text_file" title="Text file" rel="wikipedia" href="http://en.wikipedia.org/wiki/Text_file">text file, and the simplest way to do this is :

press <a class="zem_slink freebase/en/control_key" title="Control key" rel="wikipedia" href="http://en.wikipedia.org/wiki/Control_key">Ctrl+u

copy the html and paste it in a text file and save it.

Note: Ctrl+u in most browsers is for viewing the source. If you do not want to do this then you can simply do a save as and save the html <a class="zem_slink freebase/en/computer_file" title="Computer file" rel="wikipedia" href="http://en.wikipedia.org/wiki/Computer_file">file 🙂

Now time to get all the URL&#8217;s from the html:

for i in $(<a class="zem_slink freebase/en/grep" title="Grep" rel="wikipedia" href="http://en.wikipedia.org/wiki/Grep">grep video-<a class="zem_slink freebase/en/html_element" title="HTML element" rel="wikipedia" href="http://en.wikipedia.org/wiki/HTML_element">list-item |sed &#8217;s/&amp.*//&#8217;|sed &#8217;s/.*=&#8221;\(.*\)/\1/&#8217;)
do
echo &#8221;Writing $i to youtube.urls file&#8221;
echo &#8221;http://www.youtube.com$i&#8221; » ~/youtube.urls
done

Just change the filename in the above with the file that you just saved and you will get all the URL&#8217;s in the file &#8221;~/youtube.urls&#8221;. Once this is done you can simply do

youtube-dl -a ~/youtube.urls<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://www.mt-soft.com.ar/2010/04/15/a-new-way-to-gather-and-organize-your-online-content-with-weblist-me/">A New Way To Gather And Organize Your Online Content With Weblist.me (mt-soft.com.ar) <li class="zemanta-article-ul-li"><a href="http://chrisfulstow.com/counting-blank-lines-in-a-large-text-file-with-csharp-and-dotnet/">Counting blank lines in a large text file with C# and .NET (chrisfulstow.com) <li class="zemanta-article-ul-li"><a href="http://helpdeskgeek.com/linux-tips/linux-cat-command/">View Text Files Quickly in Linux (helpdeskgeek.com) <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/04/05/removereplace-textpath-in-config-file/">remove/replace text/path in config file. (amit-agarwal.co.in) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/e20839dd-9a7d-40ae-a40b-f508c0e5b70f/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b87.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">

comments powered by Disqus