Home > Uncategorized > SCPD Class Link Extractor

SCPD Class Link Extractor

At the end of every quarter I use the following greasemonkey script to extract the links of each of the classes.

Usage: Go to the current quarter SCPD page and click on each of the links. Extracting the links takes awhile, since it is based on the previous SCPD link extractor. The GM script simply goes to each lecture page and extracts the link. After extraction is finish a new tab will appear and will display all the links for you to copy and paste. (This uses the same idea as the Xanga2RSS extractor.)

It seems that the SCPD program keeps the lectures archived at these links for a pretty long time. At least for a quarter or two. (However I once googled for SCPD links and found an EE one from 07 and it still worked, so perhaps SCPD never really erases them.)

Here it is below:

// ==UserScript==
// @name           SCPD links
// @namespace      hawflakes.unoc.net
// @description    Strips video links off of SCPD
// @include        https://myvideosu.stanford.edu/*
// ==/UserScript==
 
var vidurls="";
var links;
 
// Main link page for a course
if (window.location.toString().indexOf("GradCourseInfo.aspx?")>=0)
{
// Get links to video page
links = findXPathNodes("/html/body/div[2]/div[3]/div/div/table/tbody/tr/td/a[text()='WMP']");
i=0;
 
var href=links.snapshotItem(i).getAttribute("href");
var url = href.substring(href.indexOf("'")+1);
url = url.substring(0,url.length-4);
get(url,"",getlink,i);
 
}
 
// helper functions
function findXPathNode(xpath, start,doc)
{
	var result = (doc == null ? document : doc).evaluate(xpath,(start == null ? document : start), null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE ,null);
	return (result.snapshotLength > 0 ? result.snapshotItem(0) : null);
}
 
function findXPathNodes(xpath, start,doc)
{
	return (doc == null ? document : doc).evaluate(xpath,(start == null ? document : start), null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE ,null);	
}
 
function elem(tagname,content)
{
	var ret = document.createElement(tagname);
	ret.innerHTML = content;
	return ret;
}
 
function get(url, data, cb,info) {
	var client = new XMLHttpRequest();
	client.open("GET",url,true);
	client.onreadystatechange = function () {
		if(client.readyState==4) {		
			cb(client,info);
		}
	}
	client.send(null);  
}
 
function getlink(client,info)
{
	var tempurl=client.responseText.substring(client.responseText.indexOf("<param name=\"URL\" value=\"")+"<param name=\"URL\" value=\"".length,client.responseText.indexOf(".wmv\"")+4)+"\n";
	vidurls=vidurls+tempurl;
	GM_log(tempurl);
if (info<links.snapshotLength-1)
{
	var href=links.snapshotItem(info+1).getAttribute("href");
	var url = href.substring(href.indexOf("'")+1);
	url = url.substring(0,url.length-4);
	get(url,"",getlink,info+1);
}
else
{
 //Generate links page
GM_openInTab("data:text;charset=UTF-8," + encodeURI(vidurls));
}
 
}
Categories: Uncategorized Tags: , ,
  1. anonymous
    June 4th, 2009 at 08:28 | #1

    Hi, I have installed greasemonkey and also installed the user script..
    However, when i click on the links on the current quarter page, nothing happens.
    Plz help

  2. anonymous
    June 4th, 2009 at 08:36 | #2

    This is wat i did:
    first installed greasemonkey addon
    -installed the script u have provided
    - went to https://myvideosu.stanford.edu
    - wanted to get the links of some electrical engineering courses
    so clicked on one of them.. but nothing seems to be happening
    plz help
    and i watch videos in SL if that is an issue.
    And can u tell how u got old SCPD links via google

  3. anonymous
    June 4th, 2009 at 08:46 | #3

    Sorry for spammin the comments box
    The script is working fine now..
    However would still like to know how to find links for old courses
    Want links for previous quarter’s courses

    • June 7th, 2009 at 20:45 | #4

      They don’t exist anymore. You may want to archive this quarters classes before SCPD gets rid of them.

  4. anonymous
    June 8th, 2009 at 21:00 | #5

    Hi,
    I want SCPD video lectures. I have no SCPD account :(

  5. July 22nd, 2009 at 22:31 | #7

    I need some help with the GreaseMonkey script. What exactly do you mean when you say, “Go to the current quarter SCPD page and click on each of the links” does this mean click each course page, or does it mean click each link for each video? How long does it take to generate the page full or urls, seconds, minutes?

    • August 27th, 2009 at 11:06 | #8

      usually several seconds to a few minutes

  6. Mark
    August 17th, 2009 at 13:27 | #9

    I am SCPD student.

    Is there any way to access archived lecture videos?

    • August 27th, 2009 at 11:07 | #10

      If SCPD gets rid of the videos so that the url’s don’t work there is no way to grab them.

  7. Anonymous
    August 20th, 2009 at 12:35 | #11

    Hi Jon,
    Thanks so much for your wonderful idea. I am also a Stanford student. And recently when I wanted to watch the summer 2009 classes, they have taken the classes offline already. Could you please give me the links of those classes? Thank you so much!

    • August 27th, 2009 at 11:08 | #12

      Unfortunately I cannot, since it’s against school policy.

  1. No trackbacks yet.