correct json format
This commit is contained in:
parent
17224c7413
commit
d15e3dabcb
@ -30,21 +30,29 @@ if(!empty($_GET['track'])) {
|
||||
$get_start = "/^day_start.*\$/m";
|
||||
preg_match_all($get_start, $get_ini, $match_start);
|
||||
$start_line = implode("\n", $match_start[0]);
|
||||
$start_hour = explode("= ", $start_line)[1];
|
||||
$st = date_parse(explode("= ", $start_line)[1]);
|
||||
$start_time = $st['hour'] * 3600 + $st['minute'] * 60 + $st['second'];
|
||||
|
||||
$time = date("H");
|
||||
$t = date_parse(date("H:i:s"));
|
||||
$time = $t['hour'] * 3600 + $t['minute'] * 60 + $t['second'];
|
||||
|
||||
if ($time < $start_hour) {
|
||||
if ($time < $start_time) {
|
||||
$date = date("Y-m-d", strtotime( '-1 days' ) );
|
||||
} else {
|
||||
$date = date("Y-m-d");
|
||||
}
|
||||
|
||||
$date_str = explode('-', $date);
|
||||
$xml_path = $path_root . "/" . $date_str[0] . "/" . $date_str[1] . "/" . $date . ".xml";
|
||||
$json_path = $path_root . "/" . $date_str[0] . "/" . $date_str[1] . "/" . $date . ".json";
|
||||
|
||||
if (file_exists($xml_path)) {
|
||||
$xml = simplexml_load_file($xml_path) or die("Error: Cannot create object");
|
||||
if (file_exists($json_path)) {
|
||||
$content = file_get_contents($json_path) or die("Error: Cannot create object");
|
||||
$json = json_decode($content, true);
|
||||
|
||||
list($hh, $mm, $ss) = explode(":", $json["begin"]);
|
||||
list($l_hh, $l_mm, $l_ss) = explode(":", $json["length"]);
|
||||
$begin = $hh * 3600 + $mm * 60 + $ss;
|
||||
$length = $l_hh * 3600 + $l_mm * 60 + $l_ss;
|
||||
|
||||
$src_re = array();
|
||||
$src_re[0] = '/# [0-9-]+.('.$ext.')$/';
|
||||
@ -54,17 +62,19 @@ if(!empty($_GET['track'])) {
|
||||
|
||||
$videos = array();
|
||||
|
||||
foreach($xml->body[0]->video as $video) {
|
||||
$src = preg_replace('/^\//', '', $video['src']);
|
||||
foreach($json["program"] as $video) {
|
||||
$src = preg_replace('/^\//', '', $video['source']);
|
||||
$src_arr = explode('/', $src);
|
||||
$name = preg_replace($src_re, '', end($src_arr));
|
||||
$name = str_replace('§', '?', $name);
|
||||
$begin = $video['begin'];
|
||||
$dur = $video['dur'];
|
||||
$dur = $video['duration'];
|
||||
|
||||
$in = $video['in'];
|
||||
$out = $video['out'];
|
||||
|
||||
$videos[] = array('start' => $start_hour, 'begin'=> $begin, 'src' => $name, 'dur' => $dur, 'in' => $in, 'out' => $out);
|
||||
$videos[] = array('start' => $start_time, 'begin'=> $begin, 'src' => $name, 'dur' => $dur, 'in' => $in, 'out' => $out);
|
||||
|
||||
$begin += $out - $in;
|
||||
}
|
||||
|
||||
echo json_encode($videos);
|
||||
@ -72,8 +82,8 @@ if(!empty($_GET['track'])) {
|
||||
}
|
||||
|
||||
// start / stop playout
|
||||
if(!empty($_POST['playout'])) {
|
||||
$state = $_POST['playout'];
|
||||
if(!empty($_GET['playout'])) {
|
||||
$state = $_GET['playout'];
|
||||
|
||||
if ($state === "start") {
|
||||
$out = shell_exec("./sh/playout.sh start");
|
||||
|
Loading…
x
Reference in New Issue
Block a user