Sunday, April 26, 2015

Download video lectures from Coursera

Today I came a cross Coursera website and found some great video tutorials on computer science. After going through some of the available courses, I decided to download all the files belongs to a course. However It was annoying to click on each link to download video, power point presentation, PDF document and etc. So I did a google search and found out that there are plugins for common browsers and download managers which can be used to download all the files in one go. Anyway instead of using the already available options, I decided to write my own script to download the files as I had time to kill. Writing your own software for already available solutions may not make much sense. But it will help you to learn some thing new.

I tested the script "High Performance Scientific Computing" and "The Hardware/Software Interface" pages and worked perfectly.

To download the files using the script, you want two local files.

1. Cookies information after you logged in to the Coursea site. This information can be extracted using a browser plugin. I used a plugin called "cookie.txt export". Save this information to a file called "cookies.txt".
2. Course page (html) where the links you want to get downloaded listed.

You can download the script from here,
Link: https://sites.google.com/site/blogswapoff/coursera_downloader.tar.gz?attredirects=0&d=1

Copy the script where the html page and the cookies.txt are copied. Then execute the script.
You need to provide the file name of the html page as the first argument.

E.g.: nohup ./coursera_downloader.pl Coursera_hpsc.html &

As usual, the script was executed on my Buffalo Linkstation NAS. Use nohup when you execute the script so that you can push the script to background and close the terminal if required.


root@LS-VL406:/mnt/disk1/share/downloads/courseea_files# ls -ltr
-rw-rw-r--    1 root     root         1731 Apr 26 09:37 cookies.txt
-rw-r-----    1 root     root       322767 Apr 26 16:29 Coursera_hpsc.html
-rwxr-xr-x    1 root     root         1785 Apr 26 17:43 coursera_downloader.pl
drwxr-xr-x    2 root     root           97 Apr 26 19:26 High_Performance_Scientific_Computing_Course_Overview
drwxr-xr-x    2 root     root         4096 Apr 26 19:29 Week_1_-_Introduction_to_the_Course_amp_Lecture_1
drwxr-xr-x    2 root     root         4096 Apr 26 19:33 Week_1_-_Lecture_2_Binary_storage_and_version_control
drwxr-xr-x    2 root     root         4096 Apr 26 19:36 Week_1_-_Lecture_3_Demo_of_Python_and_git
drwxr-xr-x    2 root     root         4096 Apr 26 19:40 Week_2_-_Lecture_4_Continued_demo_of_Python_and_git
drwxr-xr-x    2 root     root         4096 Apr 26 19:43 Week_2_-_Lecture_5_Python_language_features
drwxr-xr-x    2 root     root         4096 Apr 26 19:47 Week_2_-_Lecture_6_NumPy_and_timing_Python_code
drwxr-xr-x    2 root     root         4096 Apr 26 19:50 Week_2_-_Cloud_Computing_Amazon_Web_Service_Supplemental_Information
drwxr-xr-x    2 root     root         4096 Apr 26 19:53 Week_3_-_Lecture_7_Python_debugging_and_Fortran_intro
drwxr-xr-x    2 root     root         4096 Apr 26 19:56 Week_3_-_Lecture_8_Fortran_subroutines_functions_and_arrays
drwxr-xr-x    2 root     root         4096 Apr 26 19:59 Week_3_-_Lecture_9_Multi-file_codes_and_Makefiles
drwxr-xr-x    2 root     root         4096 Apr 26 20:02 Week_4_-_Lecture_10_Fortran_modules_and_Newtons_method
drwxr-xr-x    2 root     root         4096 Apr 26 20:06 Week_4_-_Lecture_11_Computer_architecture_and_memory_optimization
drwxr-xr-x    2 root     root         4096 Apr 26 20:09 Week_4_-_Lecture_12
drwxr-xr-x    2 root     root         4096 Apr 26 20:12 Week_5_-_Lecture_13
drwxr-xr-x    2 root     root         4096 Apr 26 20:16 Week_5_-_Lecture_14
drwxr-xr-x    2 root     root         4096 Apr 26 20:17 Week_5_-_Lecture_15
drwxr-xr-x    2 root     root         4096 Apr 26 20:20 Week_6_-_Lecture_16
drwxr-xr-x    2 root     root         4096 Apr 26 20:22 Week_6_-_Lecture_17
drwxr-xr-x    2 root     root         4096 Apr 26 20:26 Week_6_-_Lecture_18
drwxr-xr-x    2 root     root         4096 Apr 26 20:30 Week_7_-_Lecture_19
drwxr-xr-x    2 root     root         4096 Apr 26 20:33 Week_7_-_Lecture_20
drwxr-xr-x    2 root     root         4096 Apr 26 20:35 Week_7_-_Lecture_21
drwxr-xr-x    2 root     root         4096 Apr 26 20:38 Week_8_-_Lecture_22
drwxr-xr-x    2 root     root         4096 Apr 26 20:39 Week_8_-_Lecture_23
-rw-------    1 root     root      3386311 Apr 26 20:39 nohup.out