https://github.com/jamesnetherton/m3u
A basic golang m3u playlist parser
https://github.com/jamesnetherton/m3u
Last synced: 21 days ago
JSON representation
A basic golang m3u playlist parser
- Host: GitHub
- URL: https://github.com/jamesnetherton/m3u
- Owner: jamesnetherton
- License: mit
- Created: 2016-06-03T12:13:48.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T13:40:09.000Z (over 1 year ago)
- Last Synced: 2025-04-23T02:18:11.227Z (21 days ago)
- Language: Go
- Size: 15.6 KB
- Stars: 26
- Watchers: 2
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# M3U
[](https://github.com/jamesnetherton/m3u/actions/workflows/pr-build.yaml)
[](https://opensource.org/licenses/MIT)A basic golang [M3U playlist](https://en.wikipedia.org/wiki/M3U) parser library.
## Installation
```
go get github.com/jamesnetherton/m3u
```## Usage
Example using a local playlist:
```go
package mainimport (
"fmt"
"github.com/jamesnetherton/m3u"
)func main() {
playlist, err := m3u.Parse("testdata/playlist.m3u")if err == nil {
for _, track := range playlist.Tracks {
fmt.Println("Track name:", track.Name)
fmt.Println("Track length:", track.Length)
fmt.Println("Track URI:", track.URI)
fmt.Println("Track Tags:")
for i := range track.Tags {
fmt.Println(" -",track.Tags[i].Name,"=>",track.Tags[i].Value)}
fmt.Println("----------")
}
} else {
fmt.Println(err)
}
}
```Example using a remote playlist:
```go
package mainimport (
"fmt"
"github.com/jamesnetherton/m3u"
)func main() {
playlist, err := m3u.Parse("https://raw.githubusercontent.com/jamesnetherton/m3u/master/testdata/playlist.m3u")if err == nil {
for _, track := range playlist.Tracks {
fmt.Println("Track name:", track.Name)
fmt.Println("Track length:", track.Length)
fmt.Println("Track URI:", track.URI)
fmt.Println("Track Tags:")
for i := range track.Tags {
fmt.Println(" -",track.Tags[i].Name,"=>",track.Tags[i].Value)}
fmt.Println("----------")
}
} else {
fmt.Println(err)
}
}
```