machinepack-youtubenodemachines/youtubeAPICalls.js
function getVideos(auth, youtube, channel_id, count, callback) {
  youtube.search.list( // Call the Youtube API
  {
    auth: auth,
    part: "snippet",
    order: "date",
    maxResults : count, //integer 0-50, default 5
    channelId: channel_id
  },
  function(err, res) {
    if (err) {
      console.log("The API returned an error: " + err);
    } else {
      if (res.data.items !== undefined) { // Check if a result was found
        getVideoStatistics(auth, youtube, res.data.items, count, callback); // Get video statistics
      } else {
        callback([]);
      }
    }
  });
}
function getVideos(auth, youtube, channel_id, count, callback) {
  youtube.search.list( // Call the Youtube API
  {
    auth: auth,
    part: "snippet",
    order: "date",
    maxResults : count, //integer 0-50, default 5
    channelId: channel_id
  },
  function(err, res) {
    if (err) {
      console.log("The API returned an error: " + err);
    } else {
      if (res.data.items !== undefined) { // Check if a result was found
        getVideoStatistics(auth, youtube, res.data.items, count, callback); // Get video statistics
      } else {
        callback([]);
      }
    }
  });
}
function getVideos ( auth , youtube , channel_id , count , callback ) { youtube . search . list ( // Call the Youtube API { auth : auth , part : "snippet" , order : "date" , maxResults : count , //integer 0-50, default 5 channelId : channel_id } , function ( err , res ) { if ( err ) { console . log ( "The API returned an error: " + err ) ; } else { if ( res . data . items !== undefined ) { // Check if a result was found getVideoStatistics ( auth , youtube , res . data . items , count , callback ) ; // Get video statistics } else { callback ( [ ] ) ; } } } ) ; }
Get Youtube videos via channel ID
Get Youtube videos via channel ID