-
-
Save jamesdeantv/965b62f29686aaf483228d236a9943e6 to your computer and use it in GitHub Desktop.
List videos in a YouTube playlist with jQuery
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 playListURL = '//gdata.youtube.com/feeds/api/playlists/PLOGi5-fAu8bFt81BE77HOVzO4S4M1ZexJ?v=2&alt=json&callback=?'; | |
jq.getJSON(playListURL, function (data) { | |
var list_data = ""; | |
jq.each(data.feed.entry, function (i, item) { | |
var feedTitle = item.title.$t; | |
var feedURL = item.link[1].href; | |
var fragments = feedURL.split("/"); | |
var videoID = fragments[fragments.length - 2]; | |
var thumb = "//i1.ytimg.com/vi/" + videoID + "/mqdefault.jpg"; | |
list_data += '<li><a href="' + feedURL + '" title="' + feedTitle + '"><img src="' + thumb + '" width="267" height="160" alt="' + feedTitle + '"></li>'; | |
}); | |
jq(list_data).appendTo(".myDiv"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment