Archive

Posts Tagged ‘greasemonkey’

VLC GOMTV SQLive URL extractor

October 25th, 2010 13 comments

Update 03/11 As far as I know GOMTV has started checking for VLC specific information, so the script probably won’t produce anything that works in VLC anymore. I don’t have time to write a Lua plugin for VLC, but that would be ideal to spoof as GOMPlayer.

Update 01/11/11: Updated user script to reflect Foo’s comment below. Code updated below.

Update 10/28/10: Fixed include of which webpages the greasemonkey script runs on. Before sometimes if the url did not match the one in the instructions it would not show the link.

I’ve have a lot of WIPs so I haven’t updated any of the content on this blog frequently. However, the hassle of watching GSL streams in P.S.T. have gotten to me, and at this point I’d rather sleep than watch Idra, Check, SlayersBoxer, Nada, Fruitdealer play Starcraft 2 live. The issue is that VODs are not free from GOMTV, and the pirated Youtube streams are a bit of a hassle to find. The massive viewers on restreamed livestreams easily reduces any computer and it’s network connection to dust.

One easy work around is to just watch the live streams from GomTV, since they are free even though the VODs are not. 720p HQ quality is offered at a premium, but SQLive is free and acceptable. However, since the hours are ridiculously harsh for people living on the West Coast of North America (3 a.m. to 6 a.m.) the best solution is to just record the live stream.

Luckily someone had figured out how to extract the SQLive stream link from the GOMTV pages with¬†detailed instructions on reddit. However, the instructions are not particularly clear, and it seems GOMTV decided to change some of the URLs slightly. Last night I managed to verify that these instructions work with some modification and it seemed fairly reasonable to right a greasemonkey script, since most likely I will be extracting these links several times per day. Since this is tedious, and partially because I’m lazy, I decided to write a greasemonkey script to do extract the link while suffering from minor insomnia last night.

Usage:

  1. For GSL2, login and go to http://www.gomtv.net/2010gslopens2/live/.
  2. Link will show up in red next to “View Live” at the top of the page.

Greasyscript below: (or download vlcgomgreaser.user)

// ==UserScript==
// @name           VLCGOMGreaser
// @namespace      hawflakes.unoc.net
// @description    Get VLC link from GOMTV SQLive
// @include        http://www.gomtv.net/*/live/*
// ==/UserScript==
 
//
 
var script = findXPathNode("//div[@id=\"league_mainBody\"]/script");
var scriptcontent = script.innerHTML;
var start = scriptcontent.indexOf("goxUrl");
var start = scriptcontent.indexOf("http", start);
var url = scriptcontent.substring(start, scriptcontent.indexOf(";", start+1));
var url = url.replace(/strLevel=[^&]+/, "strLevel=SQTest");
var url = url.replace(/&title=[^;]+/, "");
 
var linkpage = get(url,"",showlink);
 
function showlink(client,info) {
	var contents = client.responseText;
	var start = contents.indexOf("LiveAddr=") + "LiveAddr=".length;
	var end = contents.indexOf(";\"/");
	var url = unescape(contents.substring(start,end));
 
	var insertion = findXPathNode("//*[@id=\"chmenu_title_container\"]");
	insertion.innerHTML += "<a href="\">"+url+"</a>";
}
 
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 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 &gt; 0 ? result.snapshotItem(0) : null);
}

UCLA Bruincast greasemonkey link ripper

March 25th, 2009 3 comments

Just a quick post on the simple greasemonkey script that rips UCLA Bruincast video links (obviously you need access). I made it for my brother, so he can download lectures for classes he would like to save. Here’s the short greasy script. (Remember, rename the urls from “http:” to “rtsp:”). To grab the DSL links simply replace ‘LAN’ with the text of the link. Enjoy!

// ==UserScript==
// @name           BruinCastPageLinks
// @namespace      hawflakes.unoc.net
// @description    Grabs Links on a page
// @include        http://www.oid.ucla.edu/webcasts/courses/*
// ==/UserScript==
 
// Greasemonkey Script written by Jonathan Wong, Copyright 2009
// Script is freeware (Use at your own risk!).
 
Links = findXPathNodes("//a[text()='LAN']/@href");
PrintString="";
 
for(i=0;i<links .snapshotLength;i++)
{
	PrintString=PrintString+Links.snapshotItem(i).value+"\n";
}
 
GM_openInTab("data:text;charset=UTF-8," + encodeURI(PrintString).replace(/&nbsp;/g,"&amp;nbsp;"));
 
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;
}
</links>
Categories: Education, Useful Apps Tags: ,

Download Stanford SCPD streams (wmv streams)

November 7th, 2008 49 comments

Since I am currently attending Stanford, and I once searched the intraweb for a solution for downloading wmv streams, but couldn’t find anything specific, I’ll post my solution here.

Normally, SCPD requires you to login and then you watch the videos streamed using some wmv player. However, should you want to rewind or seek through a stream, this will prove to be impossible. Many commercial wmv recorders are not free, and simply play the video to download it. My solution is similar to this, but it is FREE (as in beer).

What you need:

  1. Mencoder (An encoder that comes along with Mplayer) If you use windows, you should get the command-line non-gui download from the website since it will come with mencoder. Otherwise it will not.
  2. Optional: Firefox + Greasemonkey for extracting the video URL if you’re lazy like me.
  3. Optional: Python for executing mencoder and for converting http:// links to mms:// links.

To download from SCPD (or other unprotected wmv streams), simply execute the following at a command prompt:

mencoder mms://stream.wmv -ovc copy -oac copy -o output.avi
  1. Replace mms://stream.wmv is simply the url with “http:” replace with “mms:”
  2. Replace output.avi with the output file name. Extensions should govern the format that it spits out.

It will throw a bunch of text to the screen, and you simply leave the window open (or minimized) and wait for it to finish. However, since it’s free, I commonly download several streams at the same time, so when they are done I will have several streams downloaded instead of just one.

Download: Greasemonkey script for SCPD (gets links automatically when you view an SCPD video) (Updated 9/29/09)

If you are lazy like me, and don’t want to change the http://url to mms://url I’ve provided an mencoder script that, given an http url, will fill out the commandline and execute it for you. (Note: Many mac and linux users will have python already installed on their machines.)

Usage:

./stripSCPD http://url

Download: Python SCPD script

#!/usr/bin/python
 
import subprocess,sys
 
def strip(url):
    newurl = "mms"+url[url.find(":"):]
    print newurl
    vidname = url[url.rfind("/")+1:url.rfind("?")]
    print "mencoder %s -ovc copy -oac copy -o %s.avi" % (newurl,vidname)
    subprocess.Popen(["mencoder", newurl, "-ovc","copy","-oac","copy","-o", ("%s.avi" % (vidname,))])
 
if __name__=="__main__":
    strip(sys.argv[1])

Update (11/09/08):

I’ve just tried everything again in windows, and it seems to work. Note, for some reason mplayer doesn’t have the necessary codecs by default in the downloadable zip file. However, VLC, media player classic and Windows media Player seem to be able to seek. However only media player classic can increase the audio speed (in case you want to watch a stream 1.5 times fast and be able to comprehend what someone is saying even if they seem to be on helium!).

Xanga2rss

November 3rd, 2008 4 comments

This is a greasemonkey script for firefox (not sure if it works with other browsers since it uses GM_openinTab). Simply put it can generate RSS feeds for old xanga entries, should you want to download them for archiving purposes for a diary perhaps, or should you want to migrate to another blogging framework. It took me around 2 hours in the wee hours of 4-6am in the morning to write.

I was trying to figure out why people were so into wordpress. It is pretty neat! Using WordPress’s rss import feature, I have demonstrated that I can import my old xanga entries for free and painlessly.

Install Greasemonkey script: Xanga2rss

Features:

  • Handles Titles
  • Handles Dates
  • Handles Post content fairly well.

Instructions:

  1. Get Firefox, Greasemonkey Firefox-Addon (If you don’t have them both).
  2. Install using the above link.
  3. Visit a xanga blog, and look for the “Generate XML” link on the bottom of the page near the prev,next navigation links. This will open a new tab with the RSS 2.0 feed which an assortment of blogs (including wordpress) can read and import.
  4. For ease, I suggest you grab repagination, or antipagination depending on which firefox you have. Then right-click the “next” link, and goto repaginate, where you can combine shotgun amounts of pages into the current page. Go back to the first (actually never tried the other “Generate XML” links) “Generate XML” links and the resulting tab will hold all the posts.

TODO:

  1. I would like to very much figure out whether or not it would be possible to import comments via rss.