Coder Social home page Coder Social logo

gom3u-content-parser's Introduction

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

gom3u-content-parser's People

Contributors

zikwall avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

b-mounir-dev

gom3u-content-parser's Issues

Example for using CountItems

Could you please provide an example for using countItems ?
I always get the error: parser.countItems undefined

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.