Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/id3v2Public

🎵 ID3 decoding and encoding library for Go

License

NotificationsYou must be signed in to change notification settings

n10v/id3v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

package mainimport ("fmt""log""github.com/bogem/id3v2/v2")funcmain() {tag,err:=id3v2.Open("file.mp3", id3v2.Options{Parse:true})iferr!=nil {log.Fatal("Error while opening mp3 file: ",err) }defertag.Close()// Read tagsfmt.Println(tag.Artist())fmt.Println(tag.Title())// Set tagstag.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.mp3iferr=tag.Save();err!=nil {log.Fatal("Error while saving a tag: ",err)}}

Read multiple frames

pictures:=tag.GetFrames(tag.CommonID("Attached picture"))for_,f:=rangepictures {pic,ok:=f.(id3v2.PictureFrame)if!ok {log.Fatal("Couldn't assert picture frame")}// Do something with picture framefmt.Println(pic.Description)}

Encodings

For example, if you want to set comment frame with custom encoding,you may do the following:

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.


[8]ページ先頭

©2009-2025 Movatter.jp