Files
LarsandCursor c997eb500c
Deploy Test / test (push) Successful in 2m28s
Deploy Test / deploy (push) Failing after 14s
Leite Vorschaubilder und Filmstufen geschuetzt ab
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 09:40:59 +01:00

31 lines
796 B
PHP

<?php
namespace App\Domain\Media;
class HlsPlaylist
{
public function rewrite(string $playlist, string $playlistPath, callable $sign): string
{
$directory = str_replace('\\', '/', dirname($playlistPath));
$lines = preg_split("/\r\n|\n|\r/", $playlist) ?: [];
$rewritten = [];
foreach ($lines as $line) {
$value = trim($line);
if ($value === '' || str_starts_with($value, '#')) {
$rewritten[] = $line;
continue;
}
$target = str_starts_with($value, 'ableitungen/')
? $value
: ($directory === '.' ? $value : $directory.'/'.$value);
$rewritten[] = $sign($target);
}
return implode("\n", $rewritten)."\n";
}
}