<!DOCTYPE html>
<!-- Source code from http://ntic974.blogspot.com 13/07/2014 -->
<html>
<head>
<!--<script src="./jquery-2.1.1.js"></script>-->
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$(document).ready(function(){
$.getJSON("https://api.dailymotion.com/videos?channel=music&sort=visited-hour&fields=url,views_last_day,country,description&limit=100",
function( data ) {
console.log(data);
var items = [];
$.each( data, function( key, val ) {
console.log(key);
//items.push( "<li id='" + key + "'>key = " + key + " : val = " + val + "</li>" );
if (key=='list'){
//items.push("List detected");
$.each(val, function(subkey,subval){
console.log(subkey + ":" + subval);
//items.push( "<li id='" + subkey + "'>subkey = " + subkey + " : subval = " + subval + "</li>" );
$.each(subval, function(subkey2, subval2){
console.log(subkey2 + ":" + subval2);
//items.push( "<li id='" + subkey2 + "'>subkey2 = " + subkey2 + " : subval2 = " + subval2 + "</li>" );
if (subkey2=='views_last_day'){
items.push("views_last_day = " + subval2 + "<br/>");
}
if (subkey2=='url'){
items.push("<a href='" + subval2 + "'>" + subval2 + "</a><br/>");
}
});
});
}
});
$( "<ul/>", {
"class": "my-new-list",
html: items.join( "" )
}).appendTo( "body" );
});
});
</script>
</head>
<body>
</body>
</html>
dimanche 13 juillet 2014
API Dailymotion et JQuery, évolution du dernier code posté
Cette version n'affiche que les 100 premiers liens canal music pays France les plus consultés sur Dailymotion durant la dernière heure, et affiche aussi le nombre de vues sur la dernière journée, sans les sorties debug...