diff --git a/api/app/Http/Controllers/ProgramController.php b/api/app/Http/Controllers/ProgramController.php index 6716650..c3f8aaa 100644 --- a/api/app/Http/Controllers/ProgramController.php +++ b/api/app/Http/Controllers/ProgramController.php @@ -279,11 +279,18 @@ QUERY; $schema = $this->createSchedule($start, $einde); $program = $schema['schedule'][0]['program']; - $activeStudioQuery = app('db')->select("SELECT `studio` FROM `programs_schedule_webcam` WHERE `active` = 1"); - if(!count($activeStudioQuery) || !($activeStudio = $activeStudioQuery[0]->studio)) { - $activeStudio = null; - $current = null; - } else { + $activeStudio = null; + $current = null; + if($program->nonstop) { + $activeStudio = 'nonstop'; + } else { + $activeStudioQuery = app('db')->select("SELECT `studio` FROM `programs_schedule_webcam` WHERE `active` = 1"); + if(count($activeStudioQuery)) { + $activeStudio = $activeStudioQuery[0]->studio; + } + } + + if($activeStudio) { $current = $this->getTrack($activeStudio); $next = $this->getTrack($activeStudio, /* next: */ true); $current->ends($next->start); @@ -319,9 +326,7 @@ QUERY; } $text = []; - if(!$program->nonstop) { - $text[] = $program->name; - } + $current = null; if($activeStudio) { $current = $this->getTrack($activeStudio); @@ -332,11 +337,18 @@ QUERY; $current = $next; } } - - if($current && !$request->get('program_only', false) && !($current->isLayout())) { - if($current->title) $text[] = $current->title; - if($current->artist) $text[] = $currenet->artist; } + + if($request->get('program_only', false)) { + return $program->name; + } + + if(!$request->get('program_only', false)) { + if(!$program->nonstop) $text[] = $program->name; + if($current && !$current->isLayout()) { + if($current->artist) $text[] = $current->artist; + if($current->title) $text[] = $current->title; + } } return join(' - ', $text);