Created
February 13, 2013 14:51
-
-
Save nicohvi/4945092 to your computer and use it in GitHub Desktop.
Netflix oData
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>title</title> | |
<script type="text/javascript" src="assets/javascripts/jQuery.js"></script> | |
<style> | |
.big { | |
font-size: 42pt; | |
} | |
</style> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('#drama').click(function() { | |
// Build OData query | |
var movieName = $("#movieName").val(); | |
var query = "http://odata.netflix.com/Catalog/Genres(\'Dramas\')" // netflix base url | |
+ "/Titles" // top-level resource | |
+ "?$filter=AverageRating%20gt%204&$orderby=AverageRating%20desc&$select=Name,AverageRating,BoxArt,Synopsis" // filter by movie name | |
+ "&$callback=callback" // jsonp request | |
+ "&$format=json"; // json request | |
$.ajax({ | |
dataType: "jsonp", | |
url: query, | |
jsonpCallback: "callback", | |
success: callback | |
}); | |
function callback(result) { | |
var movies = result["d"]["results"]; | |
var container = $('#movieContainer'); | |
for(var i=0; i < movies.length; i++) { | |
container.append('<div><span class=\"big\">'+i+'</span>'+movies[i].Name+'</div>'+'<div>'+movies[i].Synopsis+ | |
'</div>'+'<div>'+movies[i].AverageRating+'</div>'+'<img src=\"'+movies[i].BoxArt.SmallUrl+'\"/>'+'<hr>'); | |
} | |
} | |
}); | |
}); | |
</script> | |
<h1>Netflix-lulz</h1> | |
<button id="drama">I R BUTTON</button> | |
<div id="movieContainer"></div> | |
</body> | |
</html> |
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 express = require('express'); | |
var app = express(); | |
app.use(express.static('app/')); | |
app.get('/', function(req, res){ | |
res.sendfile('app/views/index.html'); | |
}); | |
var port = process.env.PORT || 3000; | |
app.listen(port, function() { | |
console.log("Listening on " + port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment