-
-
Save EngineeredEdge/b7fe14a1491e13edccdc to your computer and use it in GitHub Desktop.
twitch_zipline_v_0_1
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
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