-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtitle.php
More file actions
39 lines (32 loc) · 1.03 KB
/
title.php
File metadata and controls
39 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
$config = require __DIR__ . '/vod-config.php';
$path = $config['files']['api'];
if (!file_exists($path) || !filesize($path)) {
echo "Aktuell wird kein VOD abgespielt";
exit;
}
$data = json_decode(file_get_contents($path), true);
if (!is_array($data) || !isset($data['title']) || trim($data['title']) === '') {
echo "Aktuell wird kein VOD abgespielt";
exit;
}
$title = $data['title'];
// Datum extrahieren
if (preg_match('/D-(\d{2}\.\d{2}\.\d{4})/', $title, $match)) {
$datum = $match[1];
} else {
// Kein Datum im Titel -> passenden Dateinamen im VOD-Ordner suchen
$datum = "";
$vodDir = $config['vod']['unc_path'];
$files = glob($vodDir . '\\*.mp4');
foreach ($files as $file) {
if (stripos($file, $title) !== false && preg_match('/D-(\d{2}\.\d{2}\.\d{4})/', $file, $match)) {
$datum = $match[1];
break;
}
}
}
// Titel bereinigen
$title = preg_replace('/ - K-VOD G-[A-Z]+ D-\d{2}\.\d{2}\.\d{4}$/', '', $title);
// Ausgabe
echo $title . ' - VOD - ' . $datum;