Skip to content

fix(m3u8): proxy EXT-X-MEDIA and I-frame playlist URIs - #978

Merged
bestZwei merged 1 commit into
LibreSpark:mainfrom
kevin9327:fix/m3u8-media-uri
Nov 12, 2026
Merged

bestZwei merged 1 commit into
LibreSpark:mainfrom
kevin9327:fix/m3u8-media-uri

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

rewriteM3u8 only rewrites URI="..." attributes on #EXT-X-KEY and #EXT-X-MAP. In a master playlist, alternate audio and subtitle renditions (#EXT-X-MEDIA:...,URI="audio/en.m3u8") and I-frame playlists (#EXT-X-I-FRAME-STREAM-INF:...,URI="iframe.m3u8") keep their original URIs.

Because the rewritten playlist is served from /api/proxy?url=..., hls.js resolves a relative rendition URI against that proxy URL and requests a wrong same-origin path (for example /api/audio/en.m3u8), and an absolute one bypasses the proxy and hits CORS. Streams with separate audio groups then play without sound or fail to load.

This adds #EXT-X-MEDIA:, #EXT-X-I-FRAME-STREAM-INF and #EXT-X-SESSION-KEY to the tags whose URI attribute is rewritten, using the same code path as KEY/MAP (already-proxied URIs are still left alone).

Test: a new case in src/lib/m3u8.test.ts with audio, subtitle and I-frame URIs fails before the change and passes after; npx vitest run src/lib/m3u8.test.ts passes (23 tests).

AI assistance: I used an AI coding assistant to help find and write this fix; I reviewed the change and ran the tests.

rewriteM3u8 only rewrote URI attributes on EXT-X-KEY and EXT-X-MAP, so
alternate audio and subtitle renditions (EXT-X-MEDIA) and I-frame
playlists in a master playlist kept their original relative URIs. The
player then resolved them against /api/proxy?url=... and requested a
wrong same-origin path.
@bestZwei
bestZwei merged commit b7009c1 into LibreSpark:main Nov 12, 2026
1 check passed
metathrone pushed a commit to metathrone/LibreTV that referenced this pull request Nov 20, 2026
fix(m3u8): proxy EXT-X-MEDIA and I-frame playlist URIs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants