-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
62 lines (53 loc) · 2.65 KB
/
index.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
62
<?php Kirby::plugin('mirthe/tvshowblock', [
'options' => [
'cache' => true
],
'tags' => [
'tvshowblock' => [
'attr' =>[
'tmdb'
],
'html' => function($tag) {
$tmdbid = $tag->tmdb;
$api_key = option('themoviedb.apiKey');
$url = "https://api.themoviedb.org/3/tv/". $tmdbid ."?api_key=" . $api_key;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$rawdata = curl_exec($ch);
curl_close($ch);
$movieinfo = json_decode($rawdata,true);
// print_r($movieinfo); exit();
$url = "https://api.themoviedb.org/3/tv/". $tmdbid ."/credits?api_key=" . $api_key;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$rawdata_credits = curl_exec($ch);
curl_close($ch);
$credits = json_decode($rawdata_credits,true);
$mijnoutput = '<div class="well">';
$mijnoutput .= '<div class="well-img"><img src="https://www.themoviedb.org/t/p/w200/'.$movieinfo['poster_path'].'" alt=""></div>';
// show first season poster, if available. might add this as an option..
// $mijnoutput .= '<div class="well-img"><img src="https://www.themoviedb.org/t/p/w200/'.$movieinfo['seasons'][0]['poster_path'].'" alt=""></div>';
$mijnoutput .= '<div class="well-body">';
$mijnoutput .= '<p><a href="https://www.themoviedb.org/tv/'.$movieinfo['id'].'">'.$movieinfo['name']."</a><br>
". $movieinfo['first_air_date'].", ".$movieinfo['status'].", ".$movieinfo['number_of_seasons']." seasons</p>";
$mijnoutput .= '<p><em>'.$movieinfo['tagline']."</em></p>";
$mijnoutput .= '<p>'.mb_strimwidth($movieinfo['overview'],0,300, '…')."</p>";
$i = 0;
$mijnoutput .= "<ul class=\"cast\">";
foreach ($credits['cast'] as $genre) {
$mijnoutput .= '<li>'. $genre['name'] . "</li>";
if (++$i == 7) break;
}
$mijnoutput .= "</ul>";
$mijnoutput .= "<ul class=\"genres\">";
foreach ($movieinfo['genres'] as $genre) {
$mijnoutput .= '<li>'. $genre['name'] . "</li>";
}
$mijnoutput .= "</ul>";
$mijnoutput .= '</div></div>';
return $mijnoutput;
}
]
]
]);
?>