我正在使用Wonder Plugin Carousel版本15.1。我正在尝试从我的YouTube频道中检索超过15个的播放列表。
我正在使用轮播播放列表集成,并且已经在我的网页上显示了2频道的播放列表。但是,当我尝试像我一样将第三频道的播放列表添加为单独的轮播时,会抛出错误。
我检查了控制台,并看到以下错误:
2wonderplugincarousel.js:216 Uncaught TypeError: Cannot read property 'replace' of undefined
at Object.success (wonderplugincarousel.js:216)
at i (jquery.js:2)
at Object.fireWith [as resolveWith] (jquery.js:2)
at y (jquery.js:4)
at XMLHttpRequest.c (jquery.js:4)
这是wonderplugincarousel.js的getingplaylist参数,看起来像
getYouTubePlaylist: function(youtubeapikey, youtubeplaylistid, youtubeplaylistmaxresults, index, insert_index, onsuccess, instance, pagetoken) {
var youtube_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=" + youtubeplaylistid + "&key=" + youtubeapikey;
if (youtubeplaylistmaxresults)
if (youtubeplaylistmaxresults > 50)
youtube_url += "&maxResults=50";
else
youtube_url += "&maxResults=" + youtubeplaylistmaxresults;
if (pagetoken)
youtube_url += "&pageToken=" + pagetoken;
var all_done = true;
$.getJSON(youtube_url, function(data) {
if (data && data.items) {
var original_item = $("li.amazingcarousel-item", instance.container).eq(index);
for (var i = 0; i < data.items.length; i++) {
var video_id = data.items[i]["snippet"]["resourceId"]["videoId"];
var thumbnail = "https://img.youtube.com/vi/" + video_id + "/0.jpg";
var image = "https://img.youtube.com/vi/" + video_id + "/0.jpg";
if (data.items[i]["snippet"]["thumbnails"] && data.items[i]["snippet"]["thumbnails"]["maxres"])
image = data.items[i]["snippet"]["thumbnails"]["maxres"]["url"];
var video = "https://www.youtube.com/embed/" + video_id;
var title = data.items[i]["snippet"]["title"];
var description = data.items[i]["snippet"]["description"];
var new_item = original_item.clone();
new_item.removeAttr("data-youtubeapikey").removeAttr("data-youtubeplaylistid").removeAttr("data-youtubeplaylistmaxresults");
var item_html = new_item.html().replace(/data-srcyt=/g, "src=").replace(/__IMAGE__/g, image).replace(/__THUMBNAIL__/g, thumbnail).replace(/__VIDEO__/g, video).replace(/__TITLE__/g, title).replace(/__DESCRIPTION__/g, description);
new_item.html(item_html);
if (instance.options.lightboxobject && new_item.find("a").hasClass("wondercarousellightbox"))
new_item.find("a").each(function() {
instance.options.lightboxobject.push(this);
$(this).off("click").click(instance.options.lightboxobject.clickHandler)
});
$("li.amazingcarousel-item", instance.container).eq(insert_index).after(new_item);
insert_index++
}
}
if (data && data.nextPageToken && youtubeplaylistmaxresults && youtubeplaylistmaxresults > 50) {
all_done = false;
instance.getYouTubePlaylist(youtubeapikey, youtubeplaylistid, youtubeplaylistmaxresults - 50, index, insert_index, onsuccess, instance, data.nextPageToken)
}
}).always(function() {
if (all_done) {
$("li.amazingcarousel-item", instance.container).eq(index).remove();
onsuccess(instance)
}
})
},
我希望显示我频道的所有播放列表,这些列表可能总共超过50个视频。
YouTube是否有任何限制来获取视频过多的结果?我还尝试通过插件增加视频响应总数,但未做任何更改。
答案 0 :(得分:0)
我有同样的问题,可能是由于Youtube V3 Api的配额使用引起的。
这里是链接:https://developers.google.com/youtube/v3/getting-started#quota