Skip to content

Instantly share code, notes, and snippets.

@anthonywebb
Created February 24, 2012 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonywebb/1901975 to your computer and use it in GitHub Desktop.
Save anthonywebb/1901975 to your computer and use it in GitHub Desktop.
function parseStreamUrl(url,i) {
// some entries are actually just direct stream urls
if (url.indexOf(".asx") !== -1 || url.indexOf(".pls") !== -1) {
request.get(url,function (error, response, body) {
if (!error && response.statusCode == 200) {
// asx hides stuff in XML
if(url.indexOf(".asx") !== -1){
var stream = $(body).find("entry:first").find("ref").attr("href");
}
// everything else should be able to be regex'd out
else {
var re=/http.+$/m;
var thisStreamArray = body.match(re);
var stream = thisStreamArray[0];
}
config.hosts[i].streamurl = stream;
}
});
}
else {
config.hosts[i].streamurl = url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment