Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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).

share|improve this question
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. – user1146332 Jan 22 at 8:23
@user1146332 I already have --user-agent set in my ~/.curlrc file (the user agent of the browser I am using). – Santosh Kumar Jan 22 at 8:24

1 Answer

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.

share|improve this answer
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?l‌​ecture_id=37 – Santosh Kumar Jan 22 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. – user1146332 Jan 22 at 9:15
What's your ~/.curlrc file? or what are passing additional to curl? – Santosh Kumar Jan 22 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) – user1146332 Jan 22 at 9:26
I get this output. – Santosh Kumar Jan 22 at 9:42
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.