Skip to content

Instantly share code, notes, and snippets.

@EngineeredEdge
Created June 26, 2015 17:18
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 EngineeredEdge/b7fe14a1491e13edccdc to your computer and use it in GitHub Desktop.
Save EngineeredEdge/b7fe14a1491e13edccdc to your computer and use it in GitHub Desktop.
twitch_zipline_v_0_1
var streams = ["freecodecamp"]; //, "storbeck", "terakilobyte",
//"habathcx","RobotCaleb","comster404","brunofin",
//"thomasballinger","noobs2ninjas","beohoff"];
function makeURL(stream) {
return "https://api.twitch.tv/kraken/streams/" + stream + '?callback=?';
}
function Streamer(streamName) {
var self = this;
this.streamName = streamName;
this.streamInfo = '';
this.parseFirst = function (data) {
console.log('First Parser')
var nextURL = data._links.channel + '?callback=?';
if (!data.stream) {
this.status = 'Not Active';
} else {
this.status = 'Active';
}
$.getJSON(nextURL, self.parseSecond);
};
this.parseSecond = function(x) {
console.log('Second Parser');
self.displayName = x.display_name;
self.logoURL = x.logo;
self.streamURL = x.url;
console.log('everything looks good here');
console.log(self);
};
this.sayHello = function() {
console.log(this.streamName,this.displayName,this.logoURL);
}
}
$(document).ready(function() {
function getStream(stream) {
var url = makeURL(stream);
var streamObj = new Streamer(stream);
$.getJSON(url).done(streamObj.parseFirst);
return streamObj;
}
streams = streams.map(getStream);
console.log('but something is lost in translation');
console.log(streams[0]);
$(".clickable-row").click(function() {
window.document.location = $(this).data("href");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment