API DM et JQuery : Obtenir les 100 meilleures videos dailymotion du canal music contenant dancehall, et les trailers associes, mis a jour en temps-reel
<!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?fields=title,url,embed_html%2Cviews_last_day%2Cviews_last_hour%2Cviews_last_month%2Cviews_last_week%2Cviews_total&channel=music&search=dancehall&sort=visited-hour&limit=5",
function( data ) {
console.log(data);
var items = [];
$.each( data, function( key, val ) {
console.log(key);
if (key=='list'){
$.each(val, function(subkey,subval){
console.log(subkey + ":" + subval);
$.each(subval, function(subkey2, subval2){
console.log(subkey2 + ":" + subval2);
var $title = '';
if (subkey2=='title'){
title = subval2;
}
if (subkey2=='url'){
items.push("<a href='" + subval2 + "'>" + title + "</a><br/>");
}
if (subkey2=='embed_html'){
//console.log(subval2);
items.push(subval2 + '<br/><br/><br/>');
}
});
});
}
});
$( "<ul/>", {
"class": "my-new-list",
html: items.join( "" )
}).appendTo( "body" );
});
});
</script>
</head>
<body>
Sorted by visited month<br/>
<br/>
</body>
</html>