-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-playlist.php
More file actions
executable file
·116 lines (93 loc) · 2.9 KB
/
Copy pathparse-playlist.php
File metadata and controls
executable file
·116 lines (93 loc) · 2.9 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env php
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use ProPresenter\Parser\ProPlaylistReader;
// Check for required argument
if ($argc < 2) {
echo "Usage: parse-playlist.php <file.proplaylist>\n";
exit(1);
}
$filePath = $argv[1];
// Try to read the playlist file
try {
$archive = ProPlaylistReader::read($filePath);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
exit(1);
}
// Display playlist header
echo "Playlist: " . $archive->getName() . "\n";
echo "UUID: " . $archive->getRootNode()->getUuid() . "\n";
// Application info
$appInfo = $archive->getDocument()->getApplicationInfo();
$platformVersion = $appInfo->getPlatformVersion();
$appVersion = $appInfo->getApplicationVersion();
$platformStr = '';
$appStr = '';
if ($platformVersion !== null) {
$platformStr = $platformVersion->getMajorVersion() . '.' . $platformVersion->getMinorVersion() . '.' . $platformVersion->getPatchVersion();
if ($platformVersion->getBuild() !== '') {
$platformStr .= ' (' . $platformVersion->getBuild() . ')';
}
}
if ($appVersion !== null) {
$appStr = $appVersion->getMajorVersion() . '.' . $appVersion->getMinorVersion() . '.' . $appVersion->getPatchVersion();
if ($appVersion->getBuild() !== '') {
$appStr .= ' (' . $appVersion->getBuild() . ')';
}
}
echo "Application: " . $platformStr . " " . $appStr . "\n";
// Document type
echo "Type: " . $archive->getType() . "\n";
echo "\n";
// Embedded files summary
$proFiles = $archive->getEmbeddedProFiles();
$mediaFiles = $archive->getEmbeddedMediaFiles();
echo "Embedded Files: " . count($proFiles) . " .pro files, " . count($mediaFiles) . " media files\n";
echo "\n";
// Entries
$entries = $archive->getEntries();
echo "Entries (" . count($entries) . "):\n";
foreach ($entries as $entry) {
$prefix = match($entry->getType()) {
'header' => '[H]',
'presentation' => '[P]',
'placeholder' => '[-]',
'cue' => '[C]',
default => '[?]',
};
echo $prefix . " " . $entry->getName();
if ($entry->isHeader()) {
$color = $entry->getHeaderColor();
if ($color) {
echo " (color: " . implode(',', $color) . ")";
}
} elseif ($entry->isPresentation()) {
$arrName = $entry->getArrangementName();
if ($arrName) {
echo " (arrangement: " . $arrName . ")";
}
$path = $entry->getDocumentPath();
if ($path) {
echo " - " . $path;
}
}
echo "\n";
}
echo "\n";
// Embedded .pro files
if (!empty($proFiles)) {
echo "Embedded .pro Files:\n";
foreach (array_keys($proFiles) as $filename) {
echo "- " . $filename . "\n";
}
echo "\n";
}
// Embedded media files
if (!empty($mediaFiles)) {
echo "Embedded Media Files:\n";
foreach (array_keys($mediaFiles) as $filename) {
echo "- " . $filename . "\n";
}
}