Skip to content

Commit

Permalink
Merge pull request #137 from mauricioabreu/missing-map-on-dumps
Browse files Browse the repository at this point in the history
Missing EXT-X-MAP attributes on dumps
  • Loading branch information
leandromoreira authored Mar 13, 2019
2 parents 02d8326 + 5d5bab1 commit a4b250e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions m3u8/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ def dumps(self):
output.append(str(self.start))
if self.is_i_frames_only:
output.append('#EXT-X-I-FRAMES-ONLY')
if self.segment_map:
map_output = []
if self.segment_map.get('uri'):
map_output.append('URI=' + quoted(self.segment_map['uri']))
if self.segment_map.get('byterange'):
map_output.append('BYTERANGE=' + self.segment_map['byterange'])
output.append('#EXT-X-MAP:' + ','.join(map_output))
if self.is_variant:
if self.media:
output.append(str(self.media))
Expand Down
10 changes: 10 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,16 @@ def test_dump_should_include_program_date_time():
assert "EXT-X-PROGRAM-DATE-TIME:2014-08-13T13:36:33+00:00" in obj.dumps().strip()


def test_dump_should_include_segment_level_program_date_time():
obj = m3u8.M3U8(playlists.DISCONTINUITY_PLAYLIST_WITH_PROGRAM_DATE_TIME)
# Tag being expected is in the segment level, not the global one
assert "#EXT-X-PROGRAM-DATE-TIME:2014-08-13T13:36:55+00:00" in obj.dumps().strip()

def test_dump_should_include_map_attributes():
obj = m3u8.M3U8(playlists.MAP_URI_PLAYLIST_WITH_BYTERANGE)

assert 'EXT-X-MAP:URI="main.mp4",BYTERANGE="812@0"' in obj.dumps().strip()

def test_dump_should_work_for_playlists_using_byteranges():
obj = m3u8.M3U8(playlists.PLAYLIST_USING_BYTERANGES)

Expand Down

0 comments on commit a4b250e

Please sign in to comment.