I am working on a project where I have an external application call a Google Apps Script Function whose purpose is to retrieve the id's of the most recent uploads on a youtube channel. The script provided by google works very well at getting the video id's:
/** * This function retrieves the user's uploaded videos by: * 1. Fetching the user's channel's. * 2. Fetching the user's "uploads" playlist. * 3. Iterating through this playlist and logs the video IDs and titles. * 4. If there is a next page of resuts, fetching it and returns to step 3. */function retrieveMyUploads() { try { // @see https://developers.google.com/youtube/v3/docs/channels/list const results = YouTube.Channels.list('contentDetails', { mine: true }); if (!results || results.items.length === 0) { console.log('No Channels found.'); return; } for (let i = 0; i < results.items.length; i++) { const item = results.items[i]; /** Get the channel ID - it's nested in contentDetails, as described in the * Channel resource: https://developers.google.com/youtube/v3/docs/channels. */ const playlistId = item.contentDetails.relatedPlaylists.uploads; let nextPageToken = null; do { // @see: https://developers.google.com/youtube/v3/docs/playlistItems/list const playlistResponse = YouTube.PlaylistItems.list('snippet', { playlistId: playlistId, maxResults: 25, pageToken: nextPageToken }); if (!playlistResponse || playlistResponse.items.length === 0) { console.log('No Playlist found.'); break; } for (let j = 0; j < playlistResponse.items.length; j++) { const playlistItem = playlistResponse.items[j]; console.log('[%s] Title: %s', playlistItem.snippet.resourceId.videoId, playlistItem.snippet.title); } nextPageToken = playlistResponse.nextPageToken; } while (nextPageToken); } } catch (err) { // TODO (developer) - Handle exception console.log('Failed with err %s', err.message); }}Unfortunately, I cannot figure out how to actually use the output of this function for my application. From what I can see, the function simply prints the id's to the execution log, but I am wondering if there is a way to put the output into an array? I have seen this SO post that accomplishing the same task. However, I am wondering if it can be done using the script that google provides in their documentation.