Skip to content

Commit

Permalink
Merge pull request #162 from sonroyaalmerol/additional-ext
Browse files Browse the repository at this point in the history
Parser support for M3Us with extra EXT tags
  • Loading branch information
sonroyaalmerol committed Sep 15, 2024
2 parents d662a2e + 90872f0 commit 89c86b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions m3u/m3u_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ func TestParseM3UFromURL(t *testing.T) {
testM3UContent := `
#EXTM3U
#EXTINF:-1 channelID="x-ID.bcc1" tvg-chno="0.0" tvg-id="bbc1" tvg-name="BBC One" group-title="UK",BBC One
#EXTVLCOPT:http-user-agent=HbbTV/1.6.1
http://example.com/bbc1
#EXTINF:-1 channelID="x-ID.bcc2" tvg-chno="0.0" tvg-id="bbc2" tvg-name="BBC Two" group-title="UK",BBC Two
#EXTVLCOPT:http-user-agent=HbbTV/1.6.1
http://example.com/bbc2
#EXTINF:-1 channelID="x-ID.cnn" tvg-chno="0.0" tvg-id="cnn" tvg-name="CNN International" group-title="News",CNN International
#EXTVLCOPT:http-user-agent=HbbTV/1.6.1
http://example.com/cnn
#EXTVLCOPT:logo=http://example.com/bbc_logo.png
#EXTINF:-1 channelID="x-ID.fox" tvg-chno="0.0" tvg-name="FOX" group-title="Entertainment",FOX
Expand Down
8 changes: 8 additions & 0 deletions m3u/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ func (instance *Parser) ParseURL(m3uURL string, m3uIndex int) error {
if strings.HasPrefix(line, "#EXTINF:") {
if scanner.Scan() {
nextLine := scanner.Text()
// skip all other #EXT tags
for strings.HasPrefix(nextLine, "#") {
if scanner.Scan() {
nextLine = scanner.Text()
} else {
break
}
}

if debug {
utils.SafeLogf("[DEBUG] Found next line for EXTINF: %s\n", nextLine)
Expand Down

0 comments on commit 89c86b1

Please sign in to comment.