Different approach to date range boundaries in LS.
This commit is contained in:
parent
ee391f6bf4
commit
83287d2722
|
@ -15,7 +15,6 @@ use App\Radio\Enums\FrontendAdapters;
|
|||
use App\Radio\Enums\StreamFormats;
|
||||
use App\Radio\Enums\StreamProtocols;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Carbon\CarbonInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use League\Flysystem\StorageAttributes;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -674,7 +673,11 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
|
||||
$customFunctionBody = [];
|
||||
|
||||
$scheduleMethod = 'schedule_' . $playlistSchedule->getIdRequired() . '_date_range';
|
||||
$scheduleVar = 'schedule_' . $playlistSchedule->getIdRequired() . '_date_range';
|
||||
|
||||
$scheduleMethod = 'check_schedule_' . $playlistSchedule->getIdRequired() . '_date_range';
|
||||
|
||||
$customFunctionBody[] = $scheduleVar . ' = ref(false)';
|
||||
$customFunctionBody[] = 'def ' . $scheduleMethod . '() =';
|
||||
|
||||
$conditions = [];
|
||||
|
@ -705,36 +708,18 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
}
|
||||
|
||||
$customFunctionBody[] = ' current_time = time()';
|
||||
$customFunctionBody[] = ' ' . implode(' and ', $conditions);
|
||||
$customFunctionBody[] = ' ' . $scheduleVar . ' := ' . implode(' and ', $conditions);
|
||||
$customFunctionBody[] = 'end';
|
||||
$customFunctionBody[] = 'thread.run(every=60., ' . $scheduleMethod . ')';
|
||||
|
||||
$event->appendLines($customFunctionBody);
|
||||
|
||||
$play_time = $scheduleMethod . '() and ' . $play_time;
|
||||
$play_time = '!' . $scheduleVar . ' and ' . $play_time;
|
||||
}
|
||||
|
||||
return $play_time;
|
||||
}
|
||||
|
||||
protected function getTimeAsLiquidsoapVariable(CarbonInterface $time): string
|
||||
{
|
||||
$params = [
|
||||
'isdst' => 'null()',
|
||||
'year' => $time->year,
|
||||
'month' => $time->month,
|
||||
'day' => $time->day,
|
||||
'hour' => $time->hour,
|
||||
'min' => $time->minute,
|
||||
'sec' => $time->second,
|
||||
];
|
||||
|
||||
$returnParams = [];
|
||||
foreach ($params as $k => $v) {
|
||||
$returnParams[] = $k . '=' . $v;
|
||||
}
|
||||
|
||||
return 'time.make({' . implode(', ', $returnParams) . '})';
|
||||
}
|
||||
|
||||
public function writeCrossfadeConfiguration(WriteLiquidsoapConfiguration $event): void
|
||||
{
|
||||
$settings = $event->getStation()->getBackendConfig();
|
||||
|
|
Loading…
Reference in New Issue