n10v / id3v2

🎵 ID3 decoding and encoding library for Go
https://pkg.go.dev/github.com/bogem/id3v2/v2
MIT License
340 stars 52 forks source link

How to read a tag from a .mp3 file like "Track", "Composer" or "Comment"? #16

Closed highend closed 7 years ago

highend commented 7 years ago

I'm slowly getting into using your library (sorry, absolute golang newbie...).

What I currently don't see: How do I read specific tags (apart from the ones that are provided by existing methods like .Artist(), .Title(), etc.)?

E.g.: Track (TRCK) Comments (COMM) or Composer (TCOM)? and eventually: DISCNUMBER?

Regards, Highend

n10v commented 7 years ago

Hello! If you want to get frames, that can be only single in tag, then you should use tag.GetLastFrame. E.g. getting a composer:

composerFramer := tag.GetLastFrame(tag.CommonID("Composer"))
if composerFramer != nil {
    composer, ok := composerFramer.(id3v2.TextFrame)
    if !ok {
        log.Fatal("Couldn't assert composer frame")
    }
    fmt.Println(composer.Text) // Print a text from composer frame
}

Other information you can find in docs

highend commented 7 years ago

Thanks a lot, got it so far (for Track, Composer, Comment and the CD number (Part of a set))!

There is one thing left I'd like to ask...

Is it possible to specify which kind of ID3v2.(3|4) tag will be used when the file is written with tag.Save()? For whatever reason, some people prefer to have their files with ID3v2.3 tags instead of ID3v2.4 ones...

Last thing: Do you accept donations (e.g. via paypal)?

n10v commented 7 years ago

Unfortunately, id3v2 doesn't support this function, but if you really want it, I can implement this functionality. It's not complicated.

Yes, I'm glad to every donation! My paypal: albertnigmatzianov@gmail.com Thank you in advance!

n10v commented 7 years ago

@highend thank you very much for donation! I really appreciate it!

highend commented 7 years ago

This would be really nice, if you can add that!

No problem! Glad that I found your library and that I finally have a command line tool (on Windows) that can read & write tags with unicode characters :)

n10v commented 7 years ago

Don't you mind, if I add it tomorrow?

n10v commented 7 years ago

@highend And actually it would be very nice, if you will open source of your CLI and upload it in GitHub. I need CLI like this but I'm a bit lazy to write it :)

highend commented 7 years ago

Take your time. Uh, this is my second day with the go programming language... But once I'm sure enough that it works properly I can put it on github, sure.

n10v commented 7 years ago

I could contribute in your cli if you need help

n10v commented 7 years ago

@highend done! Test this functions please If something works not fine, please open new issue