machinepack-youtubenodemachines/youtubeAPICalls.js
function getChannel(auth, youtube, channelID, callback) {
  youtube.channels.list( // Call the Youtube API
    {
      auth: auth,
      part: "snippet, statistics",
      order: "date",
      id: channelID,
      maxResults: 1 // Integer 0-50, default 5
    },
    function(err, res) {
      if (err) {
        console.log("The API returned an error: " + err);
      } else {
        if (res.data.items[0] !== undefined) { // Check if a result was found
          var formatedChannel = formatChannelJson(res.data.items[0]) // Format the recieved JSON object
          callback(formatedChannel);
        } else {
            callback([]);
        }
      }
    }
  );
}
function getChannel(auth, youtube, channelID, callback) {
  youtube.channels.list( // Call the Youtube API
    {
      auth: auth,
      part: "snippet, statistics",
      order: "date",
      id: channelID,
      maxResults: 1 // Integer 0-50, default 5
    },
    function(err, res) {
      if (err) {
        console.log("The API returned an error: " + err);
      } else {
        if (res.data.items[0] !== undefined) { // Check if a result was found
          var formatedChannel = formatChannelJson(res.data.items[0]) // Format the recieved JSON object
          callback(formatedChannel);
        } else {
            callback([]);
        }
      }
    }
  );
}
function getChannel ( auth , youtube , channelID , callback ) { youtube . channels . list ( // Call the Youtube API { auth : auth , part : "snippet, statistics" , order : "date" , id : channelID , maxResults : 1 // Integer 0-50, default 5 } , function ( err , res ) { if ( err ) { console . log ( "The API returned an error: " + err ) ; } else { if ( res . data . items [ 0 ] !== undefined ) { // Check if a result was found var formatedChannel = formatChannelJson ( res . data . items [ 0 ] ) // Format the recieved JSON object callback ( formatedChannel ) ; } else { callback ( [ ] ) ; } } } ) ; }
Get a Youtube channel via channel ID
Get a Youtube channel via channel ID