Metadata
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
require_once '/var/www/src/bootstrap.php';
|
||||
|
||||
$config = new Config(
|
||||
'/var/www/config/config.json',
|
||||
'/var/www/config/channels.json'
|
||||
);
|
||||
|
||||
$epg = $config->get('epg', []);
|
||||
$url = $epg['url'] ?? null;
|
||||
|
||||
if (!$url) {
|
||||
fwrite(STDERR, "Keine epg.url in config.json gesetzt.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$target = '/var/www/epg/guide.xml';
|
||||
$xzFile = $target . '.xz';
|
||||
$tmpXml = $target . '.tmp';
|
||||
|
||||
echo "Lade EPG: {$url}\n";
|
||||
|
||||
$data = file_get_contents($url);
|
||||
|
||||
if ($data === false || trim($data) === '') {
|
||||
fwrite(STDERR, "Download fehlgeschlagen oder leer.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
file_put_contents($xzFile, $data);
|
||||
|
||||
echo "Entpacke XZ...\n";
|
||||
|
||||
$command = 'xz -dc ' . escapeshellarg($xzFile) . ' > ' . escapeshellarg($tmpXml);
|
||||
exec($command, $output, $code);
|
||||
|
||||
if ($code !== 0 || !file_exists($tmpXml) || filesize($tmpXml) === 0) {
|
||||
fwrite(STDERR, "XZ konnte nicht entpackt werden.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$xml = @simplexml_load_file($tmpXml);
|
||||
|
||||
if (!$xml) {
|
||||
unlink($tmpXml);
|
||||
fwrite(STDERR, "XML ungültig.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rename($tmpXml, $target);
|
||||
|
||||
echo "guide.xml aktualisiert.\n";
|
||||
|
||||
$cache = new XmlTvCacheService(
|
||||
$target,
|
||||
$config->get('timezone', 'Europe/Vienna'),
|
||||
'/var/www/cache/guide.json'
|
||||
);
|
||||
|
||||
$cache->rebuildCache();
|
||||
|
||||
echo "guide.json und guide.version aktualisiert.\n";
|
||||
Reference in New Issue
Block a user