我正在尝试从某些播放列表中获取一些YouTube视频ID。循环开始但最终我看到主题行中的错误(在此行:var videoID = jsonVideoListResult.items [j] .contentDetails.videoId;)。
记录器结果也低于此值。我是GAS的新手,谢谢你的帮助!
[17-05-05 20:39:33:921 EDT] VideoListResult: [object Object]
[17-05-05 20:39:33:922 EDT] VideoID: _R-mvxYzOo8
[17-05-05 20:39:33:982 EDT] VideoListResult: [object Object]
[17-05-05 20:39:33:983 EDT] VideoID: -oqQxOv9HHM
[17-05-05 20:39:34:037 EDT] VideoListResult: [object Object]
[17-05-05 20:39:34:037 EDT] VideoID: WV_I9rvrzsY
[17-05-05 20:39:34:077 EDT] VideoListResult: [object Object]
//get each playlist in the array and get its video ids
var videoIdArray = [];
for (var j=0; j<playlists.length; j++) {
var videoURLprefix = 'https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=50&playlistId=';
var videoURLsuffix = '&fields=items%2FcontentDetails%2FvideoId&key=';
var playListID = String;
playListID = playlists[j];
//Logger.log(playListID);
var getVideo = UrlFetchApp.fetch(videoURLprefix + playListID + videoURLsuffix + apiKey);
var jsonVideoListResult = [];
jsonVideoListResult = JSON.parse(getVideo);
Logger.log("VideoListResult: " + jsonVideoListResult);
var videoID = jsonVideoListResult.items[j].contentDetails.videoId;
Logger.log("VideoID: " + videoID);
videoIdArray.push(videoID);
}