-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistplay.php
More file actions
61 lines (48 loc) · 1.35 KB
/
listplay.php
File metadata and controls
61 lines (48 loc) · 1.35 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
$config = require __DIR__ . '/vod-config.php';
// Konfiguration
$vod_dir = $config['vod']['unc_path'];
$playlist_path = $config['vod']['xspf_path'];
// Titel vom Parameter holen
$title = isset($_GET['title']) ? trim($_GET['title']) : '';
header('Content-Type: text/plain');
if (empty($title)) {
echo "Fehler: Kein Titel übergeben.";
exit;
}
if (!is_dir($vod_dir)) {
echo "Fehler: VOD-Verzeichnis nicht gefunden: $vod_dir";
exit;
}
// Alle MP4-Dateien durchsuchen
$files = glob($vod_dir . '\\*.mp4');
$match = null;
foreach ($files as $file) {
$filename = basename($file);
// Nur ganze Wörter / Wortgruppen matchen
$pattern = '/\b' . preg_quote($title, '/') . '\b/i';
if (preg_match($pattern, $filename)) {
$match = $file;
break;
}
}
if (!$match) {
echo "Fehler: Kein passendes Video gefunden für Titel: $title";
exit;
}
// Playlist im XSPF-Format erstellen
$escaped_path = str_replace(['\\', ' '], ['/', '%20'], $match);
$playlist = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<location>file:///$escaped_path</location>
<title>$title</title>
</track>
</trackList>
</playlist>
XML;
// Playlist speichern
file_put_contents($playlist_path, $playlist);
echo "Wiedergabeliste erstellt: $playlist_path";