Skip to content

Commit

Permalink
Issue 326: allow tags after EXTINF (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbayles authored Sep 8, 2023
1 parent ed0afc0 commit 073321e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions m3u8/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ def parse(content, strict=False, custom_tags_parser=None):
# blank lines are legal
pass

elif state["expect_segment"]:
elif (not line.startswith('#')) and (state["expect_segment"]):
_parse_ts_chunk(line, data, state)
state["expect_segment"] = False

elif state["expect_playlist"]:
elif (not line.startswith('#')) and (state["expect_playlist"]):
_parse_variant_playlist(line, data, state)
state["expect_playlist"] = False

Expand Down
8 changes: 8 additions & 0 deletions tests/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,14 @@
http://str00.iptv.domain/7331/mpegts?token=longtokenhere
"""

IPTV_PLAYLIST_WITH_EARLY_EXTINF = """#EXTM3U
#EXTVLCOPT:video-filter=invert
#EXTGRP:ExtGroup1
#EXTINF:0,Info
#EXTVLCOPT:param2=value2
http://str00.iptv.domain/7331/mpegts?token=longtokenhere
"""

LOW_LATENCY_DELTA_UPDATE_PLAYLIST = """#EXTM3U
# Following the example above, this playlist is a response to: GET https://example.com/2M/waitForMSN.php?_HLS_msn=273&_HLS_part=3&_HLS_report=../1M/waitForMSN.php&_HLS_report=../4M/waitForMSN.php&_HLS_skip=YES
#EXT-X-TARGETDURATION:4
Expand Down
7 changes: 7 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,13 @@ def parse_iptv_attributes(line, lineno, data, state):
]


def test_tag_after_extinf():
parsed_playlist = m3u8.loads(playlists.IPTV_PLAYLIST_WITH_EARLY_EXTINF)
actual = parsed_playlist.segments[0].uri
expected = 'http://str00.iptv.domain/7331/mpegts?token=longtokenhere'
assert actual == expected


def test_master_playlist_with_frame_rate():
data = m3u8.parse(playlists.VARIANT_PLAYLIST_WITH_FRAME_RATE)
playlists_list = list(data["playlists"])
Expand Down

0 comments on commit 073321e

Please sign in to comment.