This is part of my youtube project. I try to extract video information from JSON format but I have problem in this line:
var videoId = data.feed.entry[i].link[1].href;
When I do this in single line not in cikle evrithing is ok but in cikle for or while I have error.
//get youtube ID
function extract(url){
pos1=url.indexOf("videos/");
pos2=url.substr(42,11);
return pos2;
}
//My playlist LINK
var url2="http://gdata.youtube.com/feeds/api/playlists/B2A4E1367126848D?v=2&alt=json";
function playlistinfo(url1) {
$.ajax({
url: url1,
dataType: "jsonp",
success: function (data) { parseresults(data); }
});
}
//whit this get playlist data
function parseresults(data) {
//return playlist clip number
var klipove= data.feed.openSearch$totalResults.$t;
//put clips in <li>
for(i=0;i<=klipove-1;i++) {
var videoId = data.feed.entry[i].link[1].href;
//get video id ID
var id= extract(videoId);
thumb = data.feed.entry[i].media$group.media$thumbnail[0].url;
$('<li><img src="'+thumb+'" alt="'+id+'" class="thumb"/></li>').appendTo('.cont');
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…