Created
May 1, 2014 18:37
-
-
Save sammydigits/498a4a05f423cbb69e63 to your computer and use it in GitHub Desktop.
List videos in a YouTube playlist with jQuery
This file contains hidden or 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