Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts

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

Sunday, December 7, 2014

Get information about movies using perl IMDB::Film module


I got a 3 TB hard disk with a bunch of movies and I wanted to keep all the movies where the IMDB rating is greater than 7 removing all the others. Since there were hundreds of movies, I thought of automating the task.

When I Googled to find out an easier method, I found an article (http://davide.eynard.it/2011/01/20/perl-hacks-automatically-get-info-about-a-movie-from-imdb/) that describes how useful the IMDB::Film (http://search.cpan.org/~stepanov/IMDB-Film-0.53/lib/IMDB/Film.pm) perl module is for my task.

So I wrote a simple Perl script which reads movie title (in <movie name><year><other information> format) from STDIN and prints selected information about the movie to STDOUT.

e.g.:
root@LS-VL406:~/IMDB_Reader# echo 'Star Trek Into Darkness 2013 BRRip XviD AC3-SANTi' | ./GetMovieInfo.pl                     
Star Trek Into Darkness 2013 BRRip XviD AC3-SANTi,Star Trek Into Darkness,2013,movie,7.9,When the crew of the Enterprise is called back home, they find an unstoppable force of terror from within their own organization has detonated the fleet and everything it stands for, leaving our world in a state of crisis. With a personal score to settle, Captain Kirk leads a manhunt to a war-zone world to capture a one-man weapon of mass destruction. As our heroes are propelled into an epic chess game of life and death, love will be challenged, friendships will be torn apart, and sacrifices must be made for the only family Kirk has left: his crew.


This is a very simple Perl script so anyone can modify the script to add whatever information is required for a movie. Also it reads input from STDIN and prints output to STDOUT so that the unix pipe can be used for various pre and post processing such as read a movie list from a file and pipe it to the script.

I have tested this on a system which runs Fedora 20 on it and also on Buffalo linkstation NAS.

The script can be downloaded from here, All the required perl modules are included so that the user does not need to install any additional Perl modules.

https://sites.google.com/site/blogswapoff/IMDB_Reader.tar.gz