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

Issue 326: allow tags after EXTINF #327

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading