-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathomdbapi.php
101 lines (87 loc) · 3.36 KB
/
omdbapi.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
$json_data = file_get_contents("assets/secrete.json");
$json = json_decode($json_data, true);
$api_key = $json["api_key"];
$url = "https://www.omdbapi.com/?t={$query}&apikey={$api_key}";
function get_omdbapi_details($query)
{
global $query, $url;
$omdbapi_response = file_get_contents($url);
$omdbapi_json_data = json_decode($omdbapi_response, true);
$results = array();
if ($omdbapi_json_data["Response"] != "False") {
$results = [
"Response" => $omdbapi_json_data["Response"],
"imdbID" => $omdbapi_json_data["imdbID"],
"Title" => $omdbapi_json_data["Title"],
"Year" => $omdbapi_json_data["Year"],
"Rated" => $omdbapi_json_data["Rated"],
"Released" => $omdbapi_json_data["Released"],
"Runtime" => $omdbapi_json_data["Runtime"],
"Genre" => $omdbapi_json_data["Genre"],
"Director" => $omdbapi_json_data["Director"],
"Writer" => $omdbapi_json_data["Writer"],
"Actors" => $omdbapi_json_data["Actors"],
"Plot" => $omdbapi_json_data["Plot"],
"Country" => $omdbapi_json_data["Country"],
"Awards" => $omdbapi_json_data["Awards"],
"Poster" => $omdbapi_json_data["Poster"],
"Metascore" => $omdbapi_json_data["Metascore"],
"imdbRating" => $omdbapi_json_data["imdbRating"],
"Type" => $omdbapi_json_data["Type"]
];
} else {
$results = [
"Response" => $omdbapi_json_data["Response"]
];
}
return $results;
}
function print_omdbapi_details($results)
{
$config = require_once "config.php";
$libremdb_instance = get_libremdb_instance($config->libremdb_instances);
if ($results["Response"] != "False") {
$title = $results["Title"];
$imdbID = $results["imdbID"];
$year = $results["Year"];
$imdbRating = $results["imdbRating"];
$rated = $results["Rated"];
$released = $results["Released"];
$runtime = $results["Runtime"];
$genre = $results["Genre"];
$poster = $results["Poster"];
$country = $results["Country"];
$director = $results["Director"];
$actor = $results["Actors"];
echo "<div class=\"flex-column omdb-results\">";
echo "<div>";
echo "<img src=\"proxy/image_proxy.php?url=$poster\">";
echo "</div>";
echo "<div>";
echo "<h3>$title </h3>";
echo "<div class=\"movie-info\">";
echo "<img src=\"assets/star.png\" alt=\"rating \">";
echo "<span>$imdbRating </span>";
echo "<span>$runtime </span>";
echo "<span>$genre </span>";
echo "<span>$released</span>";
echo "</div>";
echo "<a style=\"font-size: smaller;\" href=\"$libremdb_instance/title/$imdbID\" target=\"_blank\">...More about series</a>";
echo "</div>";
echo "</div>";
}
}
function get_imdb_id($results)
{
global $query, $url;
$omdbapi_response = file_get_contents($url);
$omdbapi_json_data = json_decode($omdbapi_response, true);
if ($omdbapi_json_data["Response"] != "False") {
$id = $omdbapi_json_data["imdbID"];
$id = str_replace("tt", "", $id);
return $id;
} else {
return 0;
}
}