Skip to content

Instantly share code, notes, and snippets.

@christiangenco
Forked from csabapalfi/videos.js
Created March 28, 2012 11:24
Show Gist options
  • Save christiangenco/2225519 to your computer and use it in GitHub Desktop.
Save christiangenco/2225519 to your computer and use it in GitHub Desktop.
Download and Organize Coursera videos
$("h3.list_header").each(function(sectionIndex){
var sectionName = $(this).text().replace(/Chapter .+ - /,"").replace(/\:/,'-').replace(/^(V|I|X)+\. /,'');
$(this).parent().next().find("a.lecture-link").each(function(videoIndex){
var $lectureLink = $(this);
var videoName = $.trim($lectureLink.text());
var downloadLink = $lectureLink.attr('href').replace('view','download.mp4');
var cookieHeader = ' --header \"Cookie:'+ document.cookie + '\" ';
var directory = (sectionIndex+1) + '. ' + sectionName + '/';
var filename = directory + (videoIndex+1) + '. ' + videoName + '.mp4';
var cmd = 'echo "' + filename + '" && ';
cmd += 'mkdir -p "' + directory + '" && ';
cmd += 'curl -L -C - ' + cookieHeader + downloadLink + ' -o "' + filename + '"';
console.log(cmd);
});
}); null
@christiangenco
Copy link
Author

Added better file organization:

1. Section One Name/
   1. Video One Title.mp4
   2. Video Two Title.mp4
   ...
2. Section Two Name/
...

Also added some basic filtering for SAAS and Algorithms classes in video names.

@cnh
Copy link

cnh commented Mar 31, 2012

Thanks.
How do i install/run this JS file on a chrome browser ?

@christiangenco
Copy link
Author

Navigate to the video list of a Coursera page. Click View -> Developer -> JavaScript Console (or command + option + J on a mac) and paste the gist into the JS command line. The output in the JS console will be a HUGE string of bash commands (one video per line) that will download the videos into folders (creating the folders if they don't exist).

@cnh
Copy link

cnh commented Mar 31, 2012

Thanks for the prompt response Christian

One clarification
"The output in the JS console will be a HUGE string of bash commands (one video per line) that will download the videos into folders (creating the folders if they don't exist)."

Will the bash commands, generated on the JS console, get executed as well, or i copy them from the JS console, & run it in a terminal ?

Thanks a ton.

@christiangenco
Copy link
Author

Copy from the JS console and run in a terminal. Preferably in the directory you'd like your videos stored in. Let me know if it works for you!

I think I may develop this further into a bookmarklet that inserts the curl commands inline and lets you choose which videos you want included in the download...

@cnh
Copy link

cnh commented Mar 31, 2012

Thanks a lot. It works & looks like i can paste the huge blob for all the videos at 1 go.

A feature which will let you choose which videos to download would be awesome.

@christiangenco
Copy link
Author

christiangenco commented Mar 31, 2012 via email

@cnh
Copy link

cnh commented Mar 31, 2012

Just FYI, Dont go through trouble just for me :)

There are 2 alternatives, which have more features, but also take more work to get working though

  1. https://github.com/LoganDing/Coursera.org-Downloader
  2. https://github.com/jplehmann/coursera

@christiangenco
Copy link
Author

christiangenco commented Mar 31, 2012 via email

@christiangenco
Copy link
Author

@cnh
Copy link

cnh commented Mar 31, 2012 via email

@cnh
Copy link

cnh commented May 29, 2012

Hi Christian

I am using the coursera video downloader bookmarklet & it works great.

I was wondering if you know of a similar good (as in lightweight) way(bookmarklet, extension, etc) to download udacity videos (which are youtube videos & unlike coursera, not organized all on one page) ?

Thanks,
cnh

@christiangenco
Copy link
Author

Thanks! Glad you like it :D

I'd use something like a Chrome YouTube video downloader extension (a bunch exist; here's one: http://www.chromeextensions.org/other/easy-youtube-video-downloader/ ). I haven't used Udacity as much, so I can't offer any specific advise.

@cnh
Copy link

cnh commented Jun 1, 2012 via email

@christiangenco
Copy link
Author

Creepy o_O

Not back in the US yet, unfortunately. Currently enjoying a holiday to Sydney :D

@cnh
Copy link

cnh commented Jun 1, 2012 via email

@christiangenco
Copy link
Author

christiangenco commented Jun 5, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment