Skip to content

Instantly share code, notes, and snippets.

@pixelcoder
Last active August 29, 2015 14:21
Show Gist options
  • Save pixelcoder/4a05b5176496f260450e to your computer and use it in GitHub Desktop.
Save pixelcoder/4a05b5176496f260450e to your computer and use it in GitHub Desktop.
YouTube API v3: Get Playlist
var channelName = 'newformat_is_ID_not_pretty_permalink';
var vidWidth = 525;
var vidHeight = 325;
var vidResults = 6;
jQuery.get(
"https://www.googleapis.com/youtube/v3/channels", {
part: 'contentDetails',
forUsername: channelName,
key: '[API KEY]'
}, function(data){
jQuery.each(data.items, function(i, item){
pid = item.contentDetails.relatedPlaylists.uploads;
get_list_of_vids(pid);
})
}
);
function get_list_of_vids(pid){
jQuery.get(
"https://www.googleapis.com/youtube/v3/playlistItems",{
part: 'snippet',
maxResults: vidResults,
playlistId: pid,
key: '[API KEY]'
}, function(data){
jQuery.each(data.items, function(i, item){
console.log(item); // Do something - Output video iFrame? View console for OBJECT
})
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment