From 0354b25f4713a8710a1bff07af21f4e2af8d30d1 Mon Sep 17 00:00:00 2001 From: Johnnybegood90 Date: Wed, 11 Mar 2026 18:56:50 +0100 Subject: [PATCH] Correction du proxy. Fix du parsing. --- proxy.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/proxy.php b/proxy.php index 587d69a..4e5610e 100644 --- a/proxy.php +++ b/proxy.php @@ -8,7 +8,10 @@ if (empty($url) || !preg_match('#^https?://#i', $url)) { http_response_code(400); die('Invalid URL'); } -$base = preg_replace('#[^/]*(\?.*)?$#', '', $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); } }