diff --git a/m3u8/model.py b/m3u8/model.py index f5f27b3b..48bfd467 100644 --- a/m3u8/model.py +++ b/m3u8/model.py @@ -1071,7 +1071,6 @@ def find_key(keydata, keylist): def denormalize_attribute(attribute): return attribute.replace('_', '-').upper() - def quoted(string): return '"%s"' % string diff --git a/m3u8/parser.py b/m3u8/parser.py index 08b5b4d8..d6f32b86 100644 --- a/m3u8/parser.py +++ b/m3u8/parser.py @@ -320,7 +320,7 @@ def _parse_simple_parameter_raw_value(line, cast_to=str, normalize=False): param, value = line.split(':', 1) param = normalize_attribute(param.replace('#EXT-X-', '')) if normalize: - value = normalize_attribute(value) + value = value.strip().lower() return param, cast_to(value) diff --git a/tests/playlists.py b/tests/playlists.py index 9c29a773..3ec2b2d5 100755 --- a/tests/playlists.py +++ b/tests/playlists.py @@ -919,4 +919,13 @@ #EXT-X-VERSION:4 ''' +PLAYLIST_WITH_NEGATIVE_MEDIA_SEQUENCE = ''' +#EXTM3U +#EXT-X-TARGETDURATION:5220 +#EXT-X-MEDIA-SEQUENCE:-2680 +#EXTINF:5220, +http://media.example.com/entire.ts +#EXT-X-ENDLIST +''' + del abspath, dirname, join diff --git a/tests/test_parser.py b/tests/test_parser.py index cf0bd5c0..c84ef86b 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -414,3 +414,8 @@ def test_low_latency_playlist(): assert data['rendition_reports'][0]['uri'] == "../1M/waitForMSN.php" assert data['rendition_reports'][0]['last_msn'] == 273 assert data['rendition_reports'][0]['last_part'] == 3 + + +def test_negative_media_sequence(): + data = m3u8.parse(playlists.PLAYLIST_WITH_NEGATIVE_MEDIA_SEQUENCE) + assert data['media_sequence'] == -2680