Created
February 24, 2012 16:49
-
-
Save anthonywebb/1901975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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