Downloading Rails Casts

Rails casts is hosting Ruby on Rails video tutorials. It explains a lot of tips for development and how different rails components work. I highly recommend it for rails starters.

I wanted to download all the previous episodes, that needed me to open the page of each episode, find the link for the mov file, and click save as. So i created a bash script to visit the links of the episodes and do the job automatically

for ((i=$1;i<=$2;i+=1)); do
wget$i -O- | grep -oi '[a-z_0-9]*.mov' >> links
while read LINE ; do wget "$LINE" ; done < links

Now the script can be used to download any range of episodes. below i'm calling it to download episodes from the episode #1 to episode #115

./ 1 115


Ernesto said…

You script is simple and great, and it is already useful for me.

One advice though. It might simpler if in the last line you substitute the loop with

wget -i links

the -i flag in wget allows it to get the list of urls to download from the file, one url per line, which is exactly what you want in this case.

I would also add the -c flag to wget in this last line so that it doesn't re-download episodes that are already fully downloaded in the current directory, or to continue (resuming) the download for partially-downloaded episodes.
mahmoud said…
Thank you Ernesto,

I am already using the "-c" flag on my machine, but that came after the post. the "-i" flags seems perfect for me and i appreciate the hint.

one alternative enhancement i thought of is to move the wget statement into the first loop and totally remove the second loop and "links" file part..

Another thing is to accept one parameters only and in this case the script should use that parameters as its both "start" and "end" (to download one episode only)..

Popular posts from this blog

Success of Startups

Prime Numbers Generator

Android Marshmallow highlights