This commit is contained in:
2020-12-20 19:06:10 +01:00
2 changed files with 27 additions and 5 deletions

View File

@@ -271,7 +271,7 @@ QUERY;
}
/**
* Programmas nu en straks (24 uur vooruit)
* Huidige programma of nummer
*/
public function onair() {
$start = new \DateTimeImmutable('now');
@@ -284,10 +284,9 @@ QUERY;
$next = $this->getTrack(/* next: */ true);
$current->ends($next->start);
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
if($next->isLayout()) {
// return response()->json(['inProgram' => true, 'program' => $program]);
} else
$current = $next;
if(!$next->isLayout()) {
$current = $next;
}
}
return response()->json(['inProgram' => false, 'stream' => $this->isStreamEnabled(), 'current' => $current, 'program' => $program]);
@@ -297,6 +296,28 @@ QUERY;
}
}
public function onair_text() {
$start = new \DateTimeImmutable('now');
$einde = new \DateTimeImmutable('now + 1 second');
$schema = $this->createSchedule($start, $einde);
$program = $schema['schedule'][0]['program'];
if(!$program->nonstop) {
$current = $this->getTrack();
$next = $this->getTrack(/* next: */ true);
$current->ends($next->start);
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
if(!$next->isLayout()) {
$current = $next;
}
}
return $program->name . " - " . $current->title . " - " . $current->artist;
} else {
return $program->name;
}
}
/**
* Programmas nu en straks (24 uur vooruit)
*/

View File

@@ -45,6 +45,7 @@ $app->get('podcast/download/{id:\d+}/{title}', 'PodcastController@download' );
$app->get('podcast/stream/{id:\d+}/{title}', 'PodcastController@stream' );
$app->get('programma/schema/onair', 'ProgramController@onair' );
$app->get('programma/schema/onair.txt', 'ProgramController@onair_text' );
$app->get('programma/schema/nustraks', 'ProgramController@comingup' );
$app->get('programma/schema/recent', 'ProgramController@recent' );
$app->get('programma/schema/week[/{shiftWeeks:-?\d+}]', 'ProgramController@schedule' );