42 lines
978 B
PHP
42 lines
978 B
PHP
<?php
|
|
|
|
require_once '/var/www/src/bootstrap.php';
|
|
|
|
$config = new Config(
|
|
'/var/www/config/config.json',
|
|
'/var/www/config/channels.json'
|
|
);
|
|
|
|
$timezone = $config->get('timezone', 'Europe/Vienna');
|
|
$cacheFile = '/var/www/cache/guide.json';
|
|
|
|
if (!file_exists($cacheFile)) {
|
|
ApiResponse::error('guide.json not found', 404);
|
|
}
|
|
|
|
$data = json_decode(file_get_contents($cacheFile), true);
|
|
|
|
if (!is_array($data)) {
|
|
ApiResponse::error('guide.json is invalid', 500);
|
|
}
|
|
|
|
$service = new ProgrammeService($timezone);
|
|
$items = $service->getCurrentProgrammes($data, $config);
|
|
|
|
$now = new DateTimeImmutable('now', new DateTimeZone($timezone));
|
|
|
|
require_once '/var/www/src/Services/LogoService.php';
|
|
|
|
foreach ($items as &$item) {
|
|
$item['logo_url'] = LogoService::getLogoUrl($item['channel_id']);
|
|
}
|
|
|
|
unset($item);
|
|
|
|
ApiResponse::json([
|
|
'ok' => true,
|
|
'timestamp' => $now->getTimestamp(),
|
|
'datetime' => $now->format(DateTimeInterface::ATOM),
|
|
'items' => $items,
|
|
]);
|