Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/n10v/id3v2
π΅ ID3 decoding and encoding library for Go
https://github.com/n10v/id3v2
go golang id3 id3v2 music
Last synced: 20 days ago
JSON representation
π΅ ID3 decoding and encoding library for Go
- Host: GitHub
- URL: https://github.com/n10v/id3v2
- Owner: n10v
- License: mit
- Created: 2016-05-15T18:36:53.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2023-10-28T15:04:52.000Z (about 1 year ago)
- Last Synced: 2024-10-29T10:45:09.824Z (about 2 months ago)
- Topics: go, golang, id3, id3v2, music
- Language: Go
- Homepage: https://pkg.go.dev/github.com/bogem/id3v2/v2
- Size: 14 MB
- Stars: 337
- Watchers: 7
- Forks: 52
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - id3v2 - ID3 decoding and encoding library for Go. (Audio and Music)
- awesome-go - id3v2 - ID3 decoding and encoding library for Go. (Audio and Music)
- awesome-open-synth - id3v2
README
# id3v2
Implementation of ID3 v2.3 and v2.4 in native Go.
## Installation
```
go get -u github.com/bogem/id3v2/v2
```## Documentation
https://pkg.go.dev/github.com/bogem/id3v2/v2
## Usage example
```go
package mainimport (
"fmt"
"log""github.com/bogem/id3v2/v2"
)func main() {
tag, err := id3v2.Open("file.mp3", id3v2.Options{Parse: true})
if err != nil {
log.Fatal("Error while opening mp3 file: ", err)
}
defer tag.Close()// Read tags
fmt.Println(tag.Artist())
fmt.Println(tag.Title())// Set tags
tag.SetArtist("Aphex Twin")
tag.SetTitle("Xtal")comment := id3v2.CommentFrame{
Encoding: id3v2.EncodingUTF8,
Language: "eng",
Description: "My opinion",
Text: "I like this song!",
}
tag.AddCommentFrame(comment)// Write tag to file.mp3
if err = tag.Save(); err != nil {
log.Fatal("Error while saving a tag: ", err)
}
}
```## Read multiple frames
```go
pictures := tag.GetFrames(tag.CommonID("Attached picture"))
for _, f := range pictures {
pic, ok := f.(id3v2.PictureFrame)
if !ok {
log.Fatal("Couldn't assert picture frame")
}// Do something with picture frame
fmt.Println(pic.Description)
}
```## Encodings
For example, if you want to set comment frame with custom encoding,
you may do the following:```go
comment := id3v2.CommentFrame{
Encoding: id3v2.EncodingUTF16,
Language: "ger",
Description: "Tier",
Text: "Der LΓΆwe",
}
tag.AddCommentFrame(comment)
````Text` field will be automatically encoded with UTF-16BE with BOM and written to w.
UTF-8 is default for v2.4, ISO-8859-1 - for v2.3.