Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Insert YouTube Channel Feed & Player into any site using JSON
#videogroup {
width: 100%;
iframe {
width: 90%;
padding: 5%;
#myplayer .first iframe {
width: 100%;
padding: 0;
#videolist ul {
margin: 0;
padding: 0;
list-style: none;
#videolist li {
width: 50%;
float: left;
border: none;
position: relative;
#videolist li .entriestitle {
padding: 0 5px;
position: absolute;
display: none;
#videolist li:hover .entriestitle {
display: block;
width: 100%;
background: rgb(119, 25, 51);
border-radius: 10px;
color: #FFF;
padding: 10px;
opacity: .9;
z-index: 100;
right: 0;
<script type="text/javascript">
function listVideos(data) {
var firstOutput="";
var entries = data.feed.entry;
var myOutput = '<ul>';
for (var i=0; i<data.feed.entry.length; i++) {
var entriesID=entries[i].id.$t.substring(38);
var entriesTitle=entries[i].title.$t;
var entriesDescription=entries[i].media$$description.$t;
var entriesThumbnail=entries[i].media$$thumbnail[0].url;
myOutput += '<li><div class="entriestitle">' + entriesTitle + '</div>';
myOutput+='<iframe src="'+entriesID+'?wmode=transparent&amp;HD=0&amp;rel=0&amp;showinfo=0&amp;controls=1&amp;fs=1&amp;autoplay="0" frameborder="0" allowfullscreen></iframe>';
if (i==0) {
firstOutput += '<div class="first">';
firstOutput += '<h2>' + entriesTitle + '</h2>';
firstOutput += '<iframe src="'+entriesID+'?wmode=transparent&amp;HD=0&amp;rel=0&amp;showinfo=0&amp;controls=1&amp;autoplay="0" frameborder="0" allowfullscreen></iframe>';
firstOutput += '<p>' + entriesDescription + '</p>';
firstOutput += '</div>';
document.getElementById('videolist').innerHTML = myOutput;
myOutput +='</ul>';
<div id="videogroup">
<div id="myplayer"></div>
<div id="videolist"></div>
<script type="text/javascript" src=""></script>

planetoftheweb commented Apr 18, 2012

This gist lets you read a YouTube stream of video from a channel and place it on your site as a series of playable thumbnails.

You can include it in a sidebar widget in WordPress pretty easily. Just copy the code, then add a text widget in WordPress and paste the code. You might have to tweak your CSS a bit.

For right now, it will load the latest videos from the com channel that are tagged with my last name "Villalobos". To customize, simply change the name of the channel (right now lynda), how many videos you want (results=). The category is optional. One note is that the category will also work with tags. So if you're looking to view by tag or category, just feed the name under the category id.

Has anyone tried out this Youmax plugin .. shows video feeds for any channel or playlist with subscriptions

ninjazhai commented Jul 14, 2017

If anyone prefer a PHP solution, here's what I did to display YouTube channel on a webpage.

  1. Get your YouTube API Key.

  2. Use the following code to get the YouTube channel's list of videos.

    $json_link="" .
    				"&channelId=YOUR_CHANNEL_ID&part=snippet,id&order=date" .
    $json = file_get_contents($this->json_link);
    $obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);						
    foreach($obj['items'] as $post){
    	$id = isset($post['id']['videoId']) ? $post['id']['videoId'] : "";
    	$published_at = isset($post['snippet']['publishedAt']) ? $post['snippet']['publishedAt'] : "";
    	$title = isset($post['snippet']['title']) ? $post['snippet']['title'] : "";
    	$description = isset($post['snippet']['description']) ? $post['snippet']['description'] : "";
    	$thumbnail = "{$id}/maxresdefault.jpg";
    	echo "<div>
    			<div><img src='{$thumbnail}' /></div>

Here's how to get your YouTube Channel ID:

  1. Go to your YouTube channel.
  2. On the browser address bar, you will see something like this:
  3. Your YouTube channel ID is the text after /channel/. In our example above, the YouTube channel ID is UCsmyfPVdui2ZjOQSdM6CHWA

Another good solution is to use a website plugin where you don't have to maintain any code. You can follow the following steps to use this website plugin.

  1. Get a Free Key or Paid Key.

  2. Go to this login page and use the key to login.

  3. Once logged in, click “+ Create Custom Feed” button.

  4. On the pop up, name your custom YouTube channel videos feed.

  5. On the drop-down, select “YouTube Channel Videos On Your Website” option.

  6. Enter your YouTube channel ID or custom name.

  7. Click the “Proceed” button. This will show you the customization options.

  8. Click the “Embed On Website” button located on the upper-right corner of the screen.

  9. On the pop up, copy the embed code by clicking the “Copy Code” button.

  10. Paste the embed code on your website.

View live demos and learn more here.

Seems this doesn't work anymore. How would you go about retrieving all videos for a channel / user using JavaScript now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment