4

Downloading videos from Coursera is not as easy as copy and pasting the link in terminal. I also have tried exporting cookies from my browser in cookie.txt file and doing a:

curl --cookie cookie.txt "https://class.coursera.org/comnetworks-2012-001/lecture/download.mp4?lecture_id=37"

as suggested in this question but that produces a file named download.mp4?lecture_id=37 with nothing in it.

Can somebody tell me how can I download those video lectures? because downloading them with browser is a risk (I have a slow connection and if by chance if some error occurs my too much time is wasted in re-downloading it).

2
  • Maybe you have to specify the user-agent of your request via the --user-agent <agent string> switch. A common <agent string> is Mozilla/5.0. Commented Jan 22, 2013 at 8:23
  • @user1146332 I already have --user-agent set in my ~/.curlrc file (the user agent of the browser I am using). Commented Jan 22, 2013 at 8:24

3 Answers 3

2

As with any web service, the exact method changes a lot.

In the coursera-dl project, we try to do all the magic. The code involves jumping through some redirects and keeping cookies in place (which changes almost at every login), but you can run it with the --debug option to see how it calls curl or wget or your preferred downloader.

Disclaimer: I am a contributor to the project.

1

The Server responds with the status code 302 that is the requested URI moved temporarily.

If you look into the header of the http-response with

curl -i --cookie cookie.txt <URL>

and there is a valid location given, curl doesn't redo the request for this new location by default. To get curl doing this, you have to add the -L switch to the command line.

So

curl -L --cookie cookie.txt <URL>

should do the job.


Just a note: If you had used wget instead of curl you wouldn't have faced what you've described.

9
  • Are you sure that works? I'm still getting download.mp4?lecture_id=37 with curl by the method you described. wget also doesn't helps much, wget is outputing welcome?type=logout&visiting=%2Fcomnetworks-2012-001%2Flecture%2Fdownload.mp4?lecture_id=37 Commented Jan 22, 2013 at 9:12
  • It definitely works. I downloaded the video both with curl and wget. It looks like your session was finalized in the meanwhile and you have to get a new valid cookie. Commented Jan 22, 2013 at 9:15
  • What's your ~/.curlrc file? or what are passing additional to curl? Commented Jan 22, 2013 at 9:19
  • without a ~/.curlrc curl -L --user-agent "Mozilla/5.0" --cookie <COOKIE> -o <FILE> <URL> works for me (just tried it again for a second) Commented Jan 22, 2013 at 9:26
  • I get this output. Commented Jan 22, 2013 at 9:42
0

You can always use Dhulkee Coursera. It's a gui based application made specially to batch download videos from Coursera.org. Try it ou: http://dhulkeecoursera.blogspot.com.br/2014/02/dhulkee-coursera-has-gone-open-source.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .