Downloading Stanford Lectures

December 13th, 2010 by

Many Stanford classes are posted online as part of SCPD. Occasionally I get the hankering to learn something new and think that it would be great to download all of the videos from the past quarter and watch them at my leisure long after they've been removed from the SCPD website. Unfortunately, SCPD doesn't go out of its way to make it quick or easy to download the videos.

Luckily, someone named Jon went ahead and wrote two scripts that are very useful. The first is a python script that uses mencoder to download the videos if you pass it a list of links. Getting the video URLs by hand is tedious though, so Jon wrote a Greasemonkey script that grabs all of the links for you.

Unfortunately, Stanford updated its SCPD page format at some point since the script was first published, so when I tried using it the other day it kept on throwing errors. I fixed the Greasemonkey script and posted the changes back as a comment to the original blog. But the scripts are really useful, so I decided to mirror them here just in case they ever vanished from the original author's site.

So without further ado, here are slightly modified scripts (original versions here) that you can use to magically download all of the video lectures at the end of the Stanford quarter. I want to emphasize that they will only work *for current Stanford students* because you need to authenticate to get to the links page. If you are unsure about how to use Greasemonkey or python, please ask The Google.

Greasemonkey: scpd_links.user.js

13 Responses to “Downloading Stanford Lectures”

  1. Bigdoce Says:

    Hi Joey,
    Can you please indicate how can your link the file that contains the URLs (extracted using the Greasemonkey script) to the Python scrip? I tried putting the file’s full path (/Users/…..), but I received an error indicating that the / before Users is invalid syntax. Your help will be appreciated.

    I am a Mac user. Snow Leopard.

  2. jcdoll Says:

    I use relative paths, here’s an example…


    In ./fall2010/ee212 (relative to the location):

    Hope this helps.

    – joey

  3. Bigdoce Says:

    Hi Joey,
    Thank you for the timely reply. Much appreciated it. I still don’t get it fully. In your example above, is ./fall2010/ee212 the path to the folder your downloading the ee212 lectures to? Also, in the Do you have the path of the file that contains the URLs in f= open(‘ ‘, ‘r’)?

    Thanks again.

  4. jcdoll Says:

    “ee212” is a text file that contains the URLs. So when you call downloadClass(‘fall2010/ee212’), the script is opening that text file and interpreting each line of the file as a URL. The videos themselves are downloaded to the same folder that lives in.

    Make sense?

    – joey

  5. Bigdoce Says:

    It does; many thanks.
    I will give it a try and I hope you won’t mind another question if I were to run into problems.

    Thanks again.

  6. Bigdoce Says:

    Would you have an idea why I am seeing the error below?

    cd ‘/Fall2011/’ && ‘/usr/bin/pythonw’  ‘/Fall2011/’  && echo Exit status: $? && exit 1
    dn5213er:~ BigMizAC$ cd ‘/Fall2011/’ && ‘/usr/bin/pythonw’  ‘/Fall2011/’  && echo Exit status: $? && exit 1
    mencoder mms:// -ovc copy -oac copy -o 111130-msande293-znPJvX1nNNUYpTeQAp1a-500.wm.avi
    Traceback (most recent call last):
      File “/Fall2011/”, line 21, in
      File “/Fall2011/”, line 18, in downloadClass
      File “/Fall2011/”, line 11, in strip
        p1 =[“mencoder”, newurl, “-ovc”,”copy”,”-oac”,”copy”,”-o”, (“%s.avi” % (vidname,))])
      File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/”, line 444, in call
        return Popen(*popenargs, **kwargs).wait()
      File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/”, line 595, in __init__
        errread, errwrite)
      File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/”, line 1106, in _execute_child
        raise child_exception
    OSError: [Errno 2] No such file or directory

  7. jcdoll Says:

    So subprocess can’t run. You should try googling “python subprocess child_exception” and see what you can find. One thing you can do is to try adding the shell=True parameter at the end of Popen. I was just working a separate project using subprocesses and needed to include that for everything to work.

    If all else fails, it works great in Ubuntu and you could just boot off of a flash drive to get the videos you need. Better hurry though because the quarter is almost over and all of this quarter’s classes will turn into pumpkins. Good luck!

    – joey

  8. Bigdoce Says:

    Thanks again!


  9. Majaffer Says:

    Hi Joey,
    I am a level zero noob when it comes to all these things. I have a macbook pro and desperately want to download videos off SCPD before they take then down. I tried following the instructions above but to no avail. Can you please help me by sending me ‘instructions for dummies’ to download these videos? When I type in “mencoder mms://URL.wmv -ovc copy -oac copy -o Output.avi” in the terminal window in the macbookpro, it displays the message “mencoder: command not found”. Am I doing something wrong? Should I be changing some directory thing somewhere?
    Thanks a bunch man,

  10. jcdoll Says:

    MJ –
    Your first issue is installing mencoder which I can’t help you with. I haven’t used OS X in a few years so don’t recall the installation procedure. You can google “mencoder install macosx” to find instructions. After that if you run into issues just try using The Google, it’ll be much faster and more reliable than me. :)

    – joey

  11. Mike Says:

    HUGE thanks for doing this!  I spent several hours trying to get this to work on OSX, and after reading your Ubuntu comment, promptly tried in in that (in particular…using VMWare).  After easily using the software center to download mencoder, using google to setup grease monkey, setting up grease monkey to run the script when I went to the class webpage, creating the file using cut and paste into a text file as mentioned above, I’m in business.  AWESOME!

  12. Caesar DelaPaz III Says:

    For MacOSX, first install macports… then type ‘sudo port install mplayer’…. mplayer contains mencoder which now you should be able to use

  13. panagos Says:

    Hello! Thanks for the efforts! I installed gracemonkey at firefox and the scpd_links.user.js but when I open a webpage of the class, nothing happens. By reading the code of .js I would expect a new tab to open including the video links. Is this true? Any ideas? Thanks a lot!

Leave a Reply