Skip to content

zikwall/gom3u-content-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages