Downloading all related videos from youtube with youtube-dl

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 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 URL\’s in a text file, and the simplest way to do this is :

press 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 file šŸ™‚

Now time to get all the URL\’s from the html:

for i in $(grep video-list-item <filename> |sed \’s/&amp.*//\’|sed \’s/.*=\”\\(.*\\)/\\1/\’)
echo \”Writing $i to youtube.urls file\”
echo \”$i\” >> ~/youtube.urls

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


Advanced Sed Substitution Examples

This article is part of the on-going Unix Sed Tips and Tricks series. In our previous sed articles we learned ā€” sed printing, sed deletion, sed substitute , sed file write, and sed multiple commands. In this article, let us review some interesting workarounds with the ā€œsā€ substitute command in sed with several practical examples. I. […]

Read More: Unix Sed Tutorial: Advanced Sed Substitution Examples



Quick tip to change parameters in different files

for i in *.cfg; do mv $i $i.bak;sed \’s/a/b/\’ $i.bak > $i; done

The above command is very useful to change certain regular expressions in couple of files in one directory. This can be used in variety of ways to achieve a lot of things which would normally take some time to do manually.