Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dhowden/tag
ID3, MP4 and OGG/FLAC metadata parsing in Go
https://github.com/dhowden/tag
audio-data checksum flac go id3 id3v1 id3v2 mp3 mp4 ogg parsing
Last synced: 5 days ago
JSON representation
ID3, MP4 and OGG/FLAC metadata parsing in Go
- Host: GitHub
- URL: https://github.com/dhowden/tag
- Owner: dhowden
- License: bsd-2-clause
- Created: 2015-03-19T12:22:52.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-07-30T21:17:31.000Z (6 months ago)
- Last Synced: 2025-01-08T22:16:30.710Z (12 days ago)
- Topics: audio-data, checksum, flac, go, id3, id3v1, id3v2, mp3, mp4, ogg, parsing
- Language: Go
- Homepage:
- Size: 1.48 MB
- Stars: 590
- Watchers: 16
- Forks: 76
- Open Issues: 28
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MP3/MP4/OGG/FLAC metadata parsing library
[![GoDoc](https://pkg.go.dev/badge/github.com/dhowden/tag)](https://pkg.go.dev/github.com/dhowden/tag)This package provides MP3 (ID3v1,2.{2,3,4}) and MP4 (ACC, M4A, ALAC), OGG and FLAC metadata detection, parsing and artwork extraction.
Detect and parse tag metadata from an `io.ReadSeeker` (i.e. an `*os.File`):
```go
m, err := tag.ReadFrom(f)
if err != nil {
log.Fatal(err)
}
log.Print(m.Format()) // The detected format.
log.Print(m.Title()) // The title of the track (see Metadata interface for more details).
```Parsed metadata is exported via a single interface (giving a consistent API for all supported metadata formats).
```go
// Metadata is an interface which is used to describe metadata retrieved by this package.
type Metadata interface {
Format() Format
FileType() FileTypeTitle() string
Album() string
Artist() string
AlbumArtist() string
Composer() string
Genre() string
Year() intTrack() (int, int) // Number, Total
Disc() (int, int) // Number, TotalPicture() *Picture // Artwork
Lyrics() string
Comment() stringRaw() map[string]interface{} // NB: raw tag names are not consistent across formats.
}
```## Audio Data Checksum (SHA1)
This package also provides a metadata-invariant checksum for audio files: only the audio data is used to
construct the checksum.[https://pkg.go.dev/github.com/dhowden/tag#Sum](https://pkg.go.dev/github.com/dhowden/tag#Sum)
## Tools
There are simple command-line tools which demonstrate basic tag extraction and summing:
```console
$ go install github.com/dhowden/tag/cmd/tag@latest
$ cd $GOPATH/bin
$ ./tag 11\ High\ Hopes.m4a
Metadata Format: MP4
Title: High Hopes
Album: The Division Bell
Artist: Pink Floyd
Composer: Abbey Road Recording Studios/David Gilmour/Polly Samson
Year: 1994
Track: 11 of 11
Disc: 1 of 1
Picture: Picture{Ext: jpeg, MIMEType: image/jpeg, Type: , Description: , Data.Size: 606109}$ ./sum 11\ High\ Hopes.m4a
2ae208c5f00a1f21f5fac9b7f6e0b8e52c06da29
```