iheartradio / open-m3u8

Open Source m3u8 Parser
Other
245 stars 94 forks source link

Problem parsing m3u8 file #17

Closed moallemi closed 9 years ago

moallemi commented 9 years ago

Parsing the file with:

PlaylistParser parser = new PlaylistParser();
Playlist playlist = parser.parse(inputStream, Format.EXT_M3U, Extension.M3U8);

causes ParseException with message: "invalid attribute name: EXT-X-STREAM-INF - #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=101485, RESOLUTION=140x80"

m3u8 file content is:

EXTM3U

EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=101485, RESOLUTION=140x80

50k.mp4/chunk.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=151395, RESOLUTION=210x120

100k.mp4/chunk.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=300555, RESOLUTION=308x176

200k.mp4/chunk.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=500025, RESOLUTION=470x268

400k.mp4/chunk.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=1007569, RESOLUTION=756x432

900k.mp4/chunk.m3u8

What should I do then?

Wopple commented 9 years ago

Looks like PROGRAM-ID was removed from the specification so we are not going to parse it. I can change it to ignore that attribute so it doesn't throw an exception for compatibility.

Wopple commented 9 years ago

Hm, we seem to already be accounting for PROGRAM-ID. Can you provide a full stack trace?

Wopple commented 9 years ago

I tested the file and found the issue. According to this: http://tools.ietf.org/html/draft-pantos-http-live-streaming-16#section-4.2 there can be no whitespace in the attribute list. However, it looks like a lot of playlists are being distributed with whitespace anyway. The latest code on master will parse that file with the whitespace. I will work on preparing a release and let you know when it is ready.

Wopple commented 9 years ago

I released the latest code which includes a minor API change to parsing. It should be available on maven central within a couple hours. Also, 0.1.0 already supports parsing the playlist you provided so you could use that version which doesn't include the API change.

Wopple commented 9 years ago

This should be solved now.