2

我想知道播放列表(youtube)上的视频编号这是 json 播放列表的示例

http://gdata.youtube.com/feeds/api/playlists/80D426344F3DE8B6?v=2&alt=json

编码 :

var playlistURL = 'http://gdata.youtube.com/feeds/api/playlists/'+config.playlist+'?v=2&alt=json&callback=?';
var youURL = 'http://www.youtube.com/watch?v=';

//retrieve json
jQuery.getJSON(playlistURL, function(data) {

    jQuery.each(data.feed.entry, function(i, item) {
        var feedTitle = item.title.jQueryt;
        var feedURL = item.link[1].href;
        var fragments = feedURL.split("/");
        var videoID = fragments[fragments.length - 2];
        var url = youURL + videoID;
        var thumb = "http://img.youtube.com/vi/"+ videoID +"/default.jpg";
            var videosCount = ??????

    });
});

感谢先进

4

2 回答 2

0

播放列表中的视频总数存储在名为 的跨度类中item-count

var $data = $('<div>').html(data);
var videosCount = $data.find('.item-count');
于 2012-05-27T18:11:52.820 回答
0

答案是:data.feed.entry.length

于 2012-05-27T18:54:22.953 回答