HomeMediacenter/php/getseriesdata.php

57 lines
1.6 KiB
PHP
Raw Normal View History

2020-05-16 18:41:32 +00:00
<?php
$data = array('error' => true);
$myobj = new class{};
if (isset($_POST['action'])) {
$action = $_POST['action'];
if ($action == "getallseries") {
$myobj->error = false;
$list = scandir("../../Serien");
$myobj->data = array();
foreach ($list as $moviename) {
if ($moviename !== ".." && $moviename !== "." && $moviename !== "index.html") {
array_push($myobj->data,(object) array( 'name' => $moviename,
'url'=>str_replace(" ","%20",$moviename),
'thumbnail' => str_replace(" ","%20",$moviename.".jpg")));
}
}
} elseif ($action == "getseries") {
if (isset($_POST['seriesname'])) {
$myobj->error = false;
$seriesname = $_POST['seriesname'];
$list = scandir("../../Serien/".$seriesname);
//echo(json_encode($list));
$myobj->data = array();
foreach ($list as $moviename) {
if ($moviename !== ".." && $moviename !== ".") {
$tempdata = new class{};
array_push($myobj->data,(object) array( 'name' => substr($moviename, 0, -4),
'url'=>str_replace(" ","%20",$seriesname."/".$moviename),
'thumbnail' => str_replace(" ","%20",str_replace(".mp4",".jpg",$seriesname."/".$moviename)),
'seasons' => array()));
}
}
}else {
$myobj->error = true;
}
}else {
// code...
}
}else {
$myobj->error = true;
}
echo(json_encode($myobj));
?>