Change regex to parse #EXT-X-I-FRAME-STREAM-INF without trailing newline (#7851)

This commit is contained in:
Matt Norton
2026-05-15 23:04:27 -04:00
committed by GitHub
parent c3704408ac
commit 5af5a4e675
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ export type ParsedMultivariantMediaOptions = {
type LevelKeys = { [key: string]: LevelKey | undefined };
const MASTER_PLAYLIST_REGEX =
/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(I-FRAME-STREAM-INF|SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g;
/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(I-FRAME-STREAM-INF|SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)(?:[\r\n]+|$)/g;
const MASTER_PLAYLIST_MEDIA_REGEX = /#EXT-X-MEDIA:(.*)/g;
const IS_MEDIA_PLAYLIST = /^#EXT(?:INF|-X-TARGETDURATION):/m; // Handle empty Media Playlist (first EXTINF not signaled, but TARGETDURATION present)
+21
View File
@@ -58,6 +58,27 @@ http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/
expect(result.sessionData).to.equal(null);
});
it('parses #EXT-X-I-FRAME-STREAM-INF on the last line without a trailing newline', function () {
const manifest = `#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=7700000,RESOLUTION=1920x1080,CODECS="avc1.64002a"
video.m3u8
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=300000,CODECS="avc1.64002a",RESOLUTION=1920x1080,URI="iframe.m3u8"`;
const result = M3U8Parser.parseMasterPlaylist(
manifest,
'http://example.com/master.m3u8',
);
expect(result.playlistParsingError).to.be.null;
expect(result.levels).to.have.lengthOf(1);
expect(result.iframeVariants).to.have.lengthOf(1);
expect(result.iframeVariants[0].bitrate).to.equal(300000);
expect(result.iframeVariants[0].width).to.equal(1920);
expect(result.iframeVariants[0].height).to.equal(1080);
expect(result.iframeVariants[0].videoCodec).to.equal('avc1.64002a');
expect(result.iframeVariants[0].url).to.equal(
'http://example.com/iframe.m3u8',
);
});
it('parses manifest containing comment', function () {
const manifest = `#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=836280,CODECS="mp4a.40.2,avc1.64001f",RESOLUTION=848x360,NAME="480"