Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check that parameter name matches fully #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions m3u8/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ def _parse_attribute_list(prefix, line, atribute_parser):
params = ATTRIBUTELISTPATTERN.split(line.replace(prefix + ':', ''))[1::2]

attributes = {}
if not line.startswith(prefix+':') :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Could you remove that extra black space before the last colon?

return attributes

for param in params:
name, value = param.split('=', 1)
name = normalize_attribute(name)
Expand Down
12 changes: 12 additions & 0 deletions tests/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@
http://media.example.com/fileSequence52-3.ts
'''

PLAYLIST_WITH_CUSTOM_MEDIA_HEADER = '''#EXTM3U
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can name it PLAYLIST_WITH_CUSTOM_TAG because your code fixes every custom tag, not just EXT-X-MEDIA. Do you agree?

#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MEDIA-READY:7f659f6f09bce196d7
#EXT-X-KEY:METHOD=AES-128,URI="[KEY]",IV=[IV]
#EXTINF:6.0,
https://cdn.example.com/vod/hash:XXX/file.mp4/media-1.ts
#EXTINF:6.28,
https://cdn.example.com/vod/hash:XXX/file.mp4/media-2.ts
'''

PLAYLIST_WITH_SESSION_ENCRYPTED_SEGMENTS = '''
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:7794
Expand Down
4 changes: 4 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ def test_session_key_attribute_without_initialization_vector():
assert None == obj.session_keys[0].iv


def test_parse_custom_media_header():
obj = m3u8.M3U8(playlists.PLAYLIST_WITH_CUSTOM_MEDIA_HEADER)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should expect this test to assert something. I get it does not break, but what happens with the EXT-X-MEDIA-READY? Does it go away? Does it get parsed?



def test_segments_attribute():
obj = m3u8.M3U8(playlists.SIMPLE_PLAYLIST)
mock_parser_data(obj, {'segments': [{'uri': '/foo/bar-1.ts',
Expand Down