Files
TVGuide/app/src/XmlTv.php
T
2026-07-07 11:18:47 +02:00

61 lines
1.6 KiB
PHP

<?php
class XmlTv
{
private string $file;
private string $cacheFile;
private string $timezone;
private XmlTvCacheService $cacheService;
private ProgrammeService $programmeService;
public function __construct(
string $file,
string $timezone = 'Europe/Vienna',
string $cacheFile = '/var/www/cache/guide.json'
) {
$this->file = $file;
$this->timezone = $timezone;
$this->cacheFile = $cacheFile;
$this->cacheService = new XmlTvCacheService($file, $timezone, $cacheFile);
$this->programmeService = new ProgrammeService($timezone);
}
public function synchronizeChannels(Config $config): void
{
$service = new ChannelService();
$data = $this->getCachedData();
$service->synchronizeChannels($data['channels'] ?? [], $config);
}
public function load(?Config $config = null): array
{
return $this->programmeService->load($this->getCachedData(), $config);
}
public function rebuildCache(): array
{
return $this->cacheService->rebuildCache();
}
public function getCachedData(): array
{
return $this->cacheService->getCachedData();
}
public function getCurrentProgrammes(?Config $config = null): array
{
return $this->programmeService->getCurrentProgrammes($this->getCachedData(), $config);
}
public function getDayProgrammes(Config $config, string $date, ?string $channelId = null): array
{
return $this->programmeService->getDayProgrammes($config, $this->getCachedData(), $date, $channelId);
}
}