Select Git revision
api.php 8.48 KiB
<?php
include_once 'config.php';
if ($_GET['get'] == 'shows' && $_GET['limit'] && isset($_GET['offset'])) {
$output = array();
$shows = querySB('shows');
uasort($shows, function($a, $b) {
return strcmp($a['show_name'], $b['show_name']);
});
$shows = array_slice($shows, $_GET['offset'], $_GET['limit'], true);
foreach($shows as $key => $show) {
$dataShow = querySB('show', $key);
$dataSeasons = querySB('show.seasons', $key);
$seasons = array();
foreach($dataSeasons as $season => $episodes) {
array_push($seasons, array("season" => $season, "count" => count($episodes)));
}
array_push($output, array(
"id" => $key,
"name" => $show['show_name'],
"folder" => str_replace($showsPath.'/', '', $dataShow['location']),
"seasons" => $seasons
));
unset($seasons);
}
echo json_encode($output);
die;
}
if ($_GET['get'] == 'movies' && $_GET['limit'] && isset($_GET['offset'])) {
$movies = queryCP('media.list', 'type=movie&status=done&release_status=done&status_or=1');
$movies = array_slice($movies, $_GET['offset'], $_GET['limit'], true);
$output = array();
foreach ($movies as $movie) {
array_push($output, array(
"imdb" => $movie['info']['imdb'],
"title" => $movie['title'],
"year" => $movie['info']['year'],
"tagline" => $movie['info']['tagline'],
"plot" => $movie['info']['plot'],
"rating" => $movie['info']['rating']['imdb'][0].' ('.$movie['info']['rating']['imdb'][1].')',
"status" => $movie['status'],
"folder" => current(explode('/', current(str_replace($moviesPath.'/', '', $movie['releases'][release_with_file($movie['releases'])]['files']['movie']))))
));
}
echo json_encode($output);
die;
}
if ($_GET['get'] == 'poster' && (!empty($_GET['show']) || !empty($_GET['movie']))) {
if(isset($_GET['show'])) {
$type = 'show';
}else{
$type = 'movie';
}
if($_GET['show'] && $_GET['season'])
$poster = get_absolute_path('poster/'.$type.'/'.cleanName($_GET['show']).'-S'.$_GET['season'].'.jpg');
elseif($_GET['show'])
$poster = get_absolute_path('poster/'.$type.'/'.cleanName($_GET['show']).'.jpg');
else
$poster = get_absolute_path('poster/'.$type.'/'.cleanName($_GET['movie']).'.jpg');