From d9885936d96dc4ef5548a8351fa98a6948e9dcf4 Mon Sep 17 00:00:00 2001 From: mauricioabreu Date: Sun, 10 Mar 2019 13:03:40 -0300 Subject: [PATCH 1/2] Ensure segment attribute is dumped Check if #EXT-X-PROGRAM-DATE-TIME is included in the dumps output. --- tests/test_model.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_model.py b/tests/test_model.py index e7e6f886..beef8ef1 100755 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -483,6 +483,11 @@ 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_work_for_playlists_using_byteranges(): obj = m3u8.M3U8(playlists.PLAYLIST_USING_BYTERANGES) From 5d5bab1fb762725a5ff5122d77c479070100d7d5 Mon Sep 17 00:00:00 2001 From: mauricioabreu Date: Sun, 10 Mar 2019 13:56:36 -0300 Subject: [PATCH 2/2] Include EXT-X-MAP attributes on dumps These attributes were missing in the output. --- m3u8/model.py | 7 +++++++ tests/test_model.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/m3u8/model.py b/m3u8/model.py index 6154c18d..ed255636 100644 --- a/m3u8/model.py +++ b/m3u8/model.py @@ -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)) diff --git a/tests/test_model.py b/tests/test_model.py index beef8ef1..a9e94e30 100755 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -488,6 +488,11 @@ def test_dump_should_include_segment_level_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)