Skip to content

Instantly share code, notes, and snippets.

@mchambers mchambers/
Created Mar 8, 2017

What would you like to do?
App Script for retrieving the concurrent viewer count of a YouTube live stream by channel ID.
function doGet(e) {
var channelId=e.parameter["channelId"];
var results=YouTube.Search.list("snippet", {"channelId":channelId, "type":"video", "eventType":"live"})
if(results.items.length!=0) {
var broadcastResults=YouTube.Videos.list("liveStreamingDetails", {"id":results.items.pop().id.videoId});
var output={"concurrentViewers":broadcastResults.items.pop().liveStreamingDetails.concurrentViewers};
return ContentService.createTextOutput(JSON.stringify(output)).setMimeType(ContentService.MimeType.JSON);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.