/
serverreq.jag
86 lines (68 loc) · 2.64 KB
/
serverreq.jag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<%
var title = request.getParameter('q');
var title = encodeURI(title); // encode search term for rottentomatoes search
var apikey = "e9r83r3qcp3hdghg8qpu5kf3";
var moviesJSON = get("http://api.rottentomatoes.com/api/public/v1.0/movies.json", { apikey : "e9r83r3qcp3hdghg8qpu5kf3", q : title, page_limit : "1" },"json");
var i=0;
// var client = new APPClient();
// Creating an instance of AtomFeed
var feed= new Feed();
if (moviesJSON.data.movies[0] != null && moviesJSON.data.movies[0] != 'undefined') {
var videotitle = encodeURI(moviesJSON.data.movies[0].title); //encode the full movie title for youtube search
// Retrieving and online feed
var url = "http://gdata.youtube.com/feeds/api/videos?q="+videotitle+"video&start-index=1&max-results=6&v=2";
feed.getFeed(url);
// Getting an array of individual entries from the feed
var entries = feed.entries;
%>
<div class="results" id="results" >
<div id="poster">
<img src="<%=moviesJSON.data.movies[0].posters.detailed%>" alt="" />
</div>
<div class="content-about">
<h1 id="title"><%=moviesJSON.data.movies[0].title%></h1><span class="year">(<%=moviesJSON.data.movies[0].year%>)</span>
<div style="clear:both;"></div>
<div id="rating">Rating : <%=moviesJSON.data.movies[0].ratings.critics_score%>% </div> <div id="icon"><!--<img src="images/thumbsup.gif" alt="">--></div>
<div id="Starring">Starring : <%
for ( var j=0; j < moviesJSON.data.movies[0].abridged_cast.length; j++) {
print(moviesJSON.data.movies[0].abridged_cast[j].name+", ");
}
%></div>
<%
if (moviesJSON.data.movies[0].critics_consensus != null) {
%>
<div id="consensus">
Overall : <%=moviesJSON.data.movies[0].critics_consensus%> </div>
<% }
if (moviesJSON.data.movies[0].synopsis != "") {
%>
<h3>Plot</h3>
<div id="synopsis">
<%=moviesJSON.data.movies[0].synopsis%>
</div>
<%
}
%>
</div>
<div class="trailers">
<h3>Related Videos</h3>
<ul>
<%
for(var i=0;i < entries.length; i++) {
var entry = entries[i];
entry.id = entry.id.slice(27);
%>
<li>
<iframe width="300" height="150" src="http://www.youtube.com/embed/<%=entry.id%>" frameborder="0" allowfullscreen></iframe>
</li>
<%
}
%>
</ul>
</div>
</div>
<%
} else {
print("<h2>Not Found, Sorry. Try a proper full movie title</h2>");
}
%>