diff --git a/web-ui/src/lib/m3u-parser.ts b/web-ui/src/lib/m3u-parser.ts index 3ee77a45..af6fa596 100644 --- a/web-ui/src/lib/m3u-parser.ts +++ b/web-ui/src/lib/m3u-parser.ts @@ -1,5 +1,6 @@ import type { PlayerSegment } from "../mpegts"; import type { Channel, M3UMetadata, Source } from "../types/player"; +import { toPlaylistRelativePath } from "./url"; /** * Parse M3U playlist content @@ -34,7 +35,7 @@ export function parseM3U(content: string): M3UMetadata { if (line.startsWith("#EXTM3U")) { const tvgUrlMatch = line.match(/x-tvg-url="([^"]+)"/); if (tvgUrlMatch) { - tvgUrl = tvgUrlMatch[1]; + tvgUrl = toPlaylistRelativePath(tvgUrlMatch[1]); } const catchupMatch = line.match(/catchup="([^"]+)"/); if (catchupMatch) { @@ -42,7 +43,7 @@ export function parseM3U(content: string): M3UMetadata { } const catchupSourceMatch = line.match(/catchup-source="([^"]+)"/); if (catchupSourceMatch) { - defaultCatchupSource = catchupSourceMatch[1]; + defaultCatchupSource = toPlaylistRelativePath(catchupSourceMatch[1]); } continue; } @@ -77,7 +78,7 @@ export function parseM3U(content: string): M3UMetadata { tvgId: tvgIdMatch?.[1], tvgName: tvgNameMatch?.[1], catchup: catchupMatch?.[1] || defaultCatchup, - catchupSource: catchupSourceMatch?.[1] || defaultCatchupSource, + catchupSource: resolveCatchupSource(catchupSourceMatch?.[1] || defaultCatchupSource), }; continue; } @@ -87,6 +88,9 @@ export function parseM3U(content: string): M3UMetadata { // Extract optional $