Skip to content

Instantly share code, notes, and snippets.

@the-vampiire
Last active April 22, 2017 04:17
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 the-vampiire/f4fa1da17c46b9c6527ee55d3e1bd710 to your computer and use it in GitHub Desktop.
Save the-vampiire/f4fa1da17c46b9c6527ee55d3e1bd710 to your computer and use it in GitHub Desktop.
Modified status_details function
// Stream Status and Details Request
function status_details(data) {
// pulls ID attribute from convert_name data return which is passed to this request function
var id = data.users[0]._id;
$.ajax({
type: "GET",
url: "https://api.twitch.tv/kraken/streams/" + id,
headers: {
"Client-ID": "vaiynh6nnd2nxpf6wshnj4v4zxxqz2",
"Accept": "application/vnd.twitchtv.v5+json"
},
success: function (data) {
// shortcut variables
var stream = data.stream;
if (stream !== null) {
var channel = stream.channel,
name = channel.display_name,
banner = channel.profile_banner,
logo = channel.logo,
status = channel.status,
game = channel.game,
url = channel.url,
followers = channel.followers,
views = channel.views,
preview_image = stream.preview.small;
online.append(
'<div class="jumbotron channel_banner" style="height: 100px;">' +
'<div class="channel_logo"></div>' +
'<div class="text-center" style="color:white; margin-top: 20px; left: 5px">' + name + '</div>' +
'</div>'
);
channel_banner.attr('id', id);
channel_banner.attr('name', name);
$('#'+id).css('background-image', 'url("'+banner+'")');
}
// if stream is offline / null returned
else {
offline.css('display', 'block');
offline.append(
'<div class="jumbotron channel_banner" style="height: 100px;">' +
'<div class="channel_logo"></div>' +
'<div class="text-center" style="color:white; margin-top: 20px; left: 5px">' + 'OFFLINE' + '</div>' +
'</div>'
);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment