Last active
August 29, 2015 14:26
-
-
Save JamiesonRoberts/23a821a8044276589436 to your computer and use it in GitHub Desktop.
Simple script to get the videos that are part of a playlist on youtube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var playlistID = 'PLmKbqjSZR8TaNjzkuwaFOqjQibUnS2w6u'; | |
var youtubeKEY = '{YOUR-API-KEY-HERE}'; | |
var playlistJSON; | |
// This needs to be revised/updated to remove the error for a depreciation | |
function playListGet(theUrl) | |
{ | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.open( "GET", theUrl, false ); | |
xmlHttp.send( ); | |
return xmlHttp.responseText; | |
} | |
function playListRetrevial() | |
{ | |
return playListGet('https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=10&playlistId='+playlistID+"&key="+youtubeKEY); | |
} | |
playlistJSON = JSON.parse(playListRetrevial()); | |
var items = playlistJSON.items; | |
console.log(itemsArray); | |
window.onload = function() { | |
for (var i in items) { | |
var currentVid = items[i].snippet.resourceId.videoId; | |
console.log(currentVid); | |
// document.getElementById('video_container').innerHTML += '<li><iframe src="https://www.youtube.com/embed/'+currentVid+'?list='+playlistID+'" frameborder="0" allowfullscreen></iframe></li>' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment