Skip to content

Commit

Permalink
Merge pull request #3758 from video-dev/url-toolkit-mp4
Browse files Browse the repository at this point in the history
ignore query when checking for mp4 url extension
  • Loading branch information
robwalch committed Apr 12, 2021
2 parents 4346254 + 65cbaf8 commit 9c96167
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/loader/m3u8-parser.ts
Expand Up @@ -61,6 +61,10 @@ const LEVEL_PLAYLIST_REGEX_SLOW = new RegExp(

const MP4_REGEX_SUFFIX = /\.(mp4|m4s|m4v|m4a)$/i;

function isMP4Url(url: string): boolean {
return MP4_REGEX_SUFFIX.test(URLToolkit.parseURL(url)?.path ?? '');
}

export default class M3U8Parser {
static findGroup(
groups: Array<AudioGroup>,
Expand Down Expand Up @@ -511,8 +515,8 @@ export default class M3U8Parser {
// if the fragments are TS or MP4, except if we download them :/
// but this is to be able to handle SIDX.
if (
level.fragments.every((frag) =>
MP4_REGEX_SUFFIX.test(frag.relurl as string)
level.fragments.every(
(frag) => frag.relurl && isMP4Url(frag.relurl)
)
) {
logger.warn(
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/loader/playlist-loader.js
Expand Up @@ -344,6 +344,23 @@ http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/
);
});

it('handles a missing init segment for mp4 segment urls', function () {
const level = `#EXTM3U
#EXT-X-VERSION:3
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:14
#EXTINF:11.360,
/something.mp4?abc
#EXT-X-ENDLIST`;
const result = M3U8Parser.parseLevelPlaylist(
level,
'http://example.invalid/playlist.m3u8',
0
);
expect(result.initSegment).to.be.ok;
expect(result.initSegment.relurl).to.equal('/something.mp4?abc');
});

it('parse level with single char fragment URI', function () {
const level = `#EXTM3U
#EXT-X-ALLOW-CACHE:NO
Expand Down

0 comments on commit 9c96167

Please sign in to comment.