我想让用户观看YouTube的历史记录。这就是我到目前为止所做的:
function readLatestMovies() {
var results = YouTube.Channels.list('contentDetails', {mine: true});
Logger.log(results);
}
在记录器中,我收到以下回复:
[16-04-21 20:01:17:467 CEST] {kind = youtube#channelListResponse, pageInfo = {totalResults = 1,resultsPerPage = 1}, ETAG = “dj7Wjtujr8JpxjNVWXy19qVsBRI / 9D_cSFBT_DW00BBlOmm4X-jyEHU”, 项= [{种类=的YouTube#信道, ETAG = “dj7Wjtujr8JpxjNVWXy19qVsBRI / A_CrD02UoyPA7qPATfqaeKRauW4”, ID = UCUI8-QMlqUsrpDB9ECPXZng, contentDetails = {relatedPlaylists = {收藏= FLUI8-QMlqUsrpDB9ECPXZng, watchHistory = HLUI8-QMlqUsrpDB9ECPXZng, watchLater = WLUI8-QMlqUsrpDB9ECPXZng,uploads = UUUI8-QMlqUsrpDB9ECPXZng, 喜欢= LLUI8-QMlqUsrpDB9ECPXZng}}}]}
所以有 watchHistory = HLUI8-QMlqUsrpDB9ECPXZng 。 所以我的问题是:我如何才能获得似乎隐藏在变量结果中的历史记录?
提前多多感谢!
答案 0 :(得分:0)
标识HLUI8-QMlqUsrpDB9ECPXZng
是播放列表ID。要获取频道的历史记录,您需要两步:
首先,像您一样获取资源channel.list
的播放列表ID:
function readLatestMovies() {
var results = YouTube.Channels.list('contentDetails', {mine: true});
Logger.log(results);
}
更多信息:https://developers.google.com/youtube/v3/docs/channels/list
第二次,使用资源playlistItems.list
获取播放列表中的所有视频
function PLaylistHistory() {
var results = YouTube.PlaylistItems.list('snippet', {playlistId: 'HLUI8-QMlqUsrpDB9ECPXZng'});
Logger.log(results);
}
更多信息:https://developers.google.com/youtube/v3/docs/playlistItems/list
当然,您需要通过身份验证才能获得此播放列表:)