diff --git a/m3u8/parser.py b/m3u8/parser.py index 1d04c2f5..e3ee37a5 100644 --- a/m3u8/parser.py +++ b/m3u8/parser.py @@ -464,6 +464,17 @@ def _parse_cueout_cont(line, state): if len(elements) != 2: return + # EXT-X-CUE-OUT-CONT:2.436/120 style + res = re.match( + r"^[-+]?([0-9]+(\.[0-9]+)?|\.[0-9]+)/[-+]?([0-9]+(\.[0-9]+)?|\.[0-9]+)$", + elements[1] + ) + if res: + state["current_cue_out_elapsedtime"] = res.group(1) + state["current_cue_out_duration"] = res.group(3) + return + + # EXT-X-CUE-OUT-CONT:ElapsedTime=10,Duration=60,SCTE35=... style cue_info = _parse_attribute_list( protocol.ext_x_cue_out_cont, line, diff --git a/tests/playlists.py b/tests/playlists.py index 6b850493..32ed41b9 100755 --- a/tests/playlists.py +++ b/tests/playlists.py @@ -737,6 +737,26 @@ master2500_47234.ts """ +CUE_OUT_CONT_ALT_PLAYLIST = """ +#EXTM3U +#EXT-X-VERSION:3 +#EXT-X-TARGETDURATION:7 +#EXT-X-MEDIA-SEQUENCE:19980226 +#EXT-X-DISCONTINUITY-SEQUENCE:1 +#EXT-X-CUE-OUT:119.987 +#EXTINF:2.000, +segment_19980226.ts +#EXT-X-CUE-OUT-CONT:2/120 +#EXTINF:6.000, +segment_19980227.ts +#EXT-X-CUE-OUT-CONT:8/120.0 +#EXTINF:6.001, +segment_19980228.ts +#EXT-X-CUE-OUT-CONT:14.001/120.0 +#EXTINF:6.001, +segment_19980229.ts +""" + CUE_OUT_ENVIVIO_PLAYLIST = """ #EXTM3U #EXT-X-VERSION:3 diff --git a/tests/test_model.py b/tests/test_model.py index 7d0bee6b..1eae3d4a 100755 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -225,6 +225,20 @@ def test_segment_elemental_scte35_attribute(): ) +def test_segment_cue_out_cont_alt(): + obj = m3u8.M3U8(playlists.CUE_OUT_CONT_ALT_PLAYLIST) + segments = obj.segments + + assert segments[1].scte35_elapsedtime == '2' + assert segments[1].scte35_duration == '120' + + assert segments[2].scte35_elapsedtime == '8' + assert segments[2].scte35_duration == '120.0' + + assert segments[3].scte35_elapsedtime == '14.001' + assert segments[3].scte35_duration == '120.0' + + def test_segment_envivio_scte35_attribute(): obj = m3u8.M3U8(playlists.CUE_OUT_ENVIVIO_PLAYLIST) segments = obj.segments