forked from algoprog/rivr-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xinfo.php
61 lines (54 loc) · 2.19 KB
/
xinfo.php
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
<?php
require_once('includes/config.php');
require_once('includes/rivr.php');
require_once('includes/functions.php');
$type = $_GET['type'];
$q = urldecode($_GET['q']);
if($q && ($type==0||$type==1)){
$imdb_id = Rivr::findImdbId($q);
if($imdb_id>0){
$imdb_id = 'tt'.str_pad($imdb_id, 7, '0', STR_PAD_LEFT);
$mdata = json_decode(gethtml("http://www.omdbapi.com/?i=$imdb_id&plot=short&r=json"), true);
$poster = "cache/imdb_posters/$imdb_id.jpg";
if(!file_exists($poster)){
$ch = curl_init($mdata['Poster']);
$fp = fopen($poster, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
echo "<a class=\"image\" href=\"$poster\"><img src=\"$poster\" class=\"poster\"></a><span class=\"title\">{$mdata['Title']} ({$mdata['Year']}) · {$mdata['Type']}</span><br/><br/><a class=\"ptag\" href=\"http://www.imdb.com/title/$imdb_id/\" target=\"blank\">IMDB link</a><a class=\"ptag\" href=\"#\" id=\"trailer\">Watch trailer</a><br/><br/><b>IMDB rating:</b> {$mdata['imdbRating']} ({$mdata['imdbVotes']} votes)<br/>{$mdata['Rated']} · {$mdata['Runtime']} · {$mdata['Genre']} · {$mdata['Released']}<br/><br/><div id='plot'><b>Plot:</b> {$mdata['Plot']}</div><br/><b>Actors:</b> {$mdata['Actors']}";
?>
<script>
$(document).ready(function(){
var yt_url='https://content.googleapis.com/youtube/v3/search?part=snippet&type=video&videoEmbeddable=true&lr=en&orderby=viewCount&maxResults=1&hl=en&key=AIzaSyB0Jm1M4z4ffP3yFdEPFk-sd9XU5JabZLM&q=<?php echo urlencode(urldecode($mdata['Title'])); ?>+official+trailer';
$.ajax({
type: 'GET',
url: yt_url,
dataType: 'jsonp',
success: function(response){
if(response.items){
$.each(response.items, function(i,data){
var video_id=data.id.videoId;
$('#trailer').attr('href','https://www.youtube.com/watch?v='+video_id);
$('#trailer').magnificPopup({
type:'iframe',
disableOn: 700,
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
});
}
}
});
$('.image').magnificPopup({type:'image',mainClass:'mfp-fade',removalDelay: 160});
});
</script>
<?php
}
}
?>