Downloading all related videos from youtube with youtube-dl
2010-05-16
312 words
2 mins read
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’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’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 ’s/&.*//’|sed ’s/.*=”\(.*\)/\1/’)
do
echo ”Writing $i to youtube.urls file”
echo ”http://www.youtube.com$i” » ~/youtube.urls
done
Just change the filename in the above with the file that you just saved and you will get all the URL’s in the file ”~/youtube.urls”. 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">
Related Articles:
- 2010/03/16 Linux find command – Find file and directories faster and easier
- 2010/05/11 Firefox 4.0 mockups for LInux/Windows and Mac
- 2010/05/03 Download youtube video directly from the command line with youtube-dl
- 2010/03/16 prepend to a file with sponge from moreutils
- 2010/05/10 coproc help - a new feature in bash