2021年2月10日星期三

Can I get YouTube video tag using Google Application Script?

I want to send an email once new YouTube video was published. I need to somehow select what video will trigger the email. I thought I would use tags. But how can I access the tags?

I am using this sample script to list all my videos. It works well but I do not know how to access the tags. From the searches I have done here on SO and Google it seems to me that is not possible using Google Application Script but the documentation PlaylistItems says ... For example, in a playlist resource, the snippet property contains properties like author, title, description, **TAGS**, and timeCreated. As such, if you set part=snippet, the API response will contain all of those properties...

So it looks like that I might be able to get tags of videos. Could someone help me how?

function retrieveMyUploads() {    var results = YouTube.Channels.list('contentDetails', {mine: true});    for(var i in results.items) {      var item = results.items[i];      // Get the playlist ID, which is nested in contentDetails, as described in the      // Channel resource: https://developers.google.com/youtube/v3/docs/channels      var playlistId = item.contentDetails.relatedPlaylists.uploads;        var nextPageToken = '';        // This loop retrieves a set of playlist items and checks the nextPageToken in the      // response to determine whether the list contains additional items. It repeats that process      // until it has retrieved all of the items in the list.      while (nextPageToken != null) {        var playlistResponse = YouTube.PlaylistItems.list('snippet', {          playlistId: playlistId,          maxResults: 25,          pageToken: nextPageToken        });          for (var j = 0; j < playlistResponse.items.length; j++) {          var playlistItem = playlistResponse.items[j];          Logger.log('[%s] Title: %s',                     playlistItem.snippet.resourceId.videoId,                     playlistItem.snippet.title);          }        nextPageToken = playlistResponse.nextPageToken;      }    }  }  
https://stackoverflow.com/questions/66147387/can-i-get-youtube-video-tag-using-google-application-script February 11, 2021 at 09:03AM

没有评论:

发表评论