Select Git revision
api.php 12.33 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);
}
header('Content-Type: application/json');
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']))))
));
}
header('Content-Type: application/json');
echo json_encode($output);
die;
}
if ($_GET['get'] == 'comics' && $_GET['limit'] && isset($_GET['offset'])) {
$comics = queryML('getIndex');
$comics = array_slice($comics, $_GET['offset'], $_GET['limit'], true);
$output = array();
foreach ($comics as $comic) {
$issues = queryML('getComic', $comic['ComicID']);
array_push($output, array(
"id" => $comic['ComicID'],
"title" => $comic['ComicName'],
"year" => $comic['ComicYear'],
"publisher" => $comic['ComicPublisher'],
"have" => $comic['Have'],