HTML Auto Embedding Recent Uploaded videos from a youtube channel

后端 未结 3 2001
野性不改
野性不改 2020-11-28 10:19

I was wondering is there was a way to Auto Embed recent uploads from a YouTube channel to a website? I don\'t even know where to start. Help?

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 11:01

    Use the following code to auto-embed the latest video from a YouTube channel by specifying the channel ID instead of the channel name.

    var channelID = "UC0xXUfNSFQN3qOmf_G_nT5w";
    var reqURL = "https://www.youtube.com/feeds/videos.xml?channel_id=";
    $.getJSON("https://api.rss2json.com/v1/api.json?rss_url=" + encodeURIComponent(reqURL)+channelID, function(data) {
       var link = data.items[0].link;
       var id = link.substr(link.indexOf("=")+1);
    $("#youtube_video").attr("src","https://youtube.com/embed/"+id + "?controls=0&showinfo=0&rel=0");
    });
    
    

    Source: https://codegena.com/auto-embed-latest-video-youtube-channel/

提交回复
热议问题