Correction du proxy. Fix du parsing.

This commit is contained in:
Johnnybegood90
2026-03-11 18:56:50 +01:00
parent 2a74ba7cdf
commit 0354b25f47
+7 -2
View File
@@ -9,6 +9,9 @@ if (empty($url) || !preg_match('#^https?://#i', $url)) {
}
$base = preg_replace('#[^/]*(\?.*)?$#', '', $url);
$origin = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST);
$port = parse_url($url, PHP_URL_PORT);
if ($port) $origin .= ':' . $port;
$path = parse_url($url, PHP_URL_PATH) ?? '';
$is_segment = preg_match('#\.(ts|aac|mp4|m4s|fmp4)(\?|$)#i', $path);
@@ -83,12 +86,14 @@ if ($is_segment) {
$line = rtrim($line);
if ($line === '' || $line[0] === '#') {
$line = preg_replace_callback('/URI="([^"]+)"/', function($m) use ($base, $proxy_base) {
$seg = strpos($m[1], 'http') === 0 ? $m[1] : $base . $m[1];
$seg = strpos($m[1], 'http') === 0 ? $m[1]
: ($m[1][0] === '/' ? $origin . $m[1] : $base . $m[1]);
return 'URI="' . $proxy_base . urlencode($seg) . '"';
}, $line);
$out[] = $line;
} else {
$seg = strpos($line, 'http') === 0 ? $line : $base . $line;
$seg = strpos($line, 'http') === 0 ? $line
: ($line[0] === '/' ? $origin . $line : $base . $line);
$out[] = $proxy_base . urlencode($seg);
}
}