Skip to content

Latest commit

 

History

History
92 lines (70 loc) · 1.92 KB

README.md

File metadata and controls

92 lines (70 loc) · 1.92 KB

Golang m3u Content Parser

Minimalistic, functional and easy to use playlist parser

Example usage

package main

import (
	"encoding/json"
	"fmt"
	gom3uparser "github.com/zikwall/gom3u-content-parser"
)

func main() {
	parser := gom3uparser.NewM3UContentParser().
		LoadSource("https://iptv-org.github.io/iptv/countries/ru.m3u", false).
		Parse()

	jsonOutput, _ := json.Marshal(parser.Offset(2).Limit(3).All())

	fmt.Println(string(jsonOutput))
}

More example

func main() {
	parser := gom3uparser.NewM3UContentParser().
		LoadSource("https://iptv-org.github.io/iptv/countries/ru.m3u", false).
		Parse()

	for _, item := range parser.Limit(10).All() {
		fmt.Println(fmt.Sprintf("Language is: %s, Group is: %s", item.TvgLanguage, item.GroupTitle))
	}
}

Get tvg url

fmt.Println(parser.GetTvgUrl())

Installation

go get github.com/zikwall/gom3u-content-parser

Available m3u item attributes, every all string type

Formats

Origin tvg-id, tvg-logo transform to TvgId and TvgLogo objects

  • Id
  • TvgId
  • TvgName
  • TvgUrl
  • TvgLogo
  • TvgCountry
  • TvgLanguage
  • TvgShift
  • AudioTrack
  • AudioTrackNum
  • Censored
  • GroupId
  • GroupTitle
  • ExtGrp
  • ExtraAttributes (all original attributes in m3u item after parsing)

Available methods & props in parser

  • GetTvgUrl() : string
  • GetM3UContent() : string
  • GetDirtyItems() : []string - Return m3u item lines before parsing
  • GetItems() : []M3UItem - Return all items after parsing
  • Offset(int offset) : M3UContentParser - Set offset for returned results
  • Limit(int limit) : M3UContentParser - Set limits for returned results
  • Cache
  • Refresh
  • CountItems
  • TvgUrl

Questions?

For all questions and suggestions - welcome to Issues