taglib

package
v0.0.0-...-f369c56 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2014 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

README

gotaglib

Apache-licensed audio tag decoding library written in pure go. Designed to mirror the structure of taglib without being a direct port.

tl;dr

go get github.com/hjfreyer/gotaglib
import "github.com/hjfreyer/gotaglib"
...
func main() {
    f, err := os.Open("song.mp3")
    tag, err := gotaglib.Decode(f)
    fmt.Print(tag.Title())
}

Features

Currently has basic read support for id3v2.3 and id3v2.4. No writing support yet.

Goals

  • Pure go.
  • Not necessarily feature complete, but future compatible.
  • Good interfaces.
  • Handle errors properly (don't panic).

Why didn't you just use… ?

There are many other Go projects which do tag parsing, but all the ones I found violate at least one of the goals above.

Why don't you support… ?

Probably no reason other than it hasn't happened yet. If you need a particular format, or an additional feature, or you've found a file which gotaglib should parse but doesn't, please create an issue, or better yet, send a patch.

Documentation

Overview

Package taglib provides utilities for parsing audio tags in various formats.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrUnrecognizedFormat = errors.New("taglib: format not recognized")
)

Functions

This section is empty.

Types

type GenericTag

type GenericTag interface {
	Title() string
	Artist() string
	Album() string
	Comment() string
	Genre() string
	Year() time.Time
	Track() uint32
	Disc() uint32

	// CustomFrames returns non-standard, user-defined frames as a map from
	// descriptions (e.g. "PERFORMER", "MusicBrainz Album Id", etc.) to
	// values.
	CustomFrames() map[string]string

	// TagSize returns the total size of the tag's header and frames,
	// i.e. the position at which audio data starts.
	TagSize() uint32
}

GenericTag is implemented by all the tag types in this project. It gives an incomplete view of the information in each tag type, but is good enough for most purposes.

func Decode

func Decode(r io.ReaderAt, size int64) (GenericTag, error)

Decode reads r and determines which tag format the data is in, if any, and calls the decoding function for that format. size indicates the total number of bytes accessible through r.

Example
f, err := os.Open("testdata/test24.mp3")
if err != nil {
	panic(err)
}
fi, err := f.Stat()
if err != nil {
	panic(err)
}
tag, err := Decode(f, fi.Size())
if err != nil {
	panic(err)
}

fmt.Println("Title:", tag.Title())
fmt.Println("Artist:", tag.Artist())
fmt.Println("Album:", tag.Album())
fmt.Println("Genre:", tag.Genre())
fmt.Println("Year:", tag.Year())
fmt.Println("Disc:", tag.Disc())
fmt.Println("Track:", tag.Track())
fmt.Println("Performer:", tag.CustomFrames()["PERFORMER"])
Output:

Title: Test Name
Artist: Test Artist
Album: Test Album
Genre: Classical
Year: 2008-01-01 00:00:00 +0000 UTC
Disc: 3
Track: 7
Performer: Somebody

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL