How to get a youtube playlist using javascript API and json

后端 未结 3 1980
后悔当初
后悔当初 2020-12-07 18:09

This is part of my youtube project. I try to extract video information from JSON format but I have problem in this line:

var videoId = data.feed.entry[i].li         


        
3条回答
  •  自闭症患者
    2020-12-07 18:56

    Simplified the solution and got rid of the string manipulation stuff.

    var playListURL = 'http://gdata.youtube.com/feeds/api/playlists/B2A4E1367126848D?v=2&alt=json&callback=?';
    var videoURL= 'http://www.youtube.com/watch?v=';
    
    var vids = new Array();
    
    $.getJSON(playListURL, function(data) {
        $.each(data.feed.entry, function(i, item) {
            vids.push( item["media$group"]["yt$videoid"]["$t"] );
        });
    
        console.log( vids );
    });
    

提交回复
热议问题