HomeMediacenter/php/getmoviedata.php

33 lines
749 B
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 == "getmovies") {
$myobj->error = false;
$list = scandir("../../Filme");
$myobj->data = array();
foreach ($list as $moviename) {
if (strpos($moviename, '.mp4') !== false) {
array_push($myobj->data,(object) array( 'name' => substr($moviename, 0, -4),
'url'=>str_replace(" ","%20",$moviename),
'thumbnail' => str_replace(" ","%20",str_replace(".mp4",".jpg",$moviename))));
}
}
} else {
// code...
}
}else {
$myobj->error = true;
}
echo(json_encode($myobj));
?>