n10v / id3v2

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

pre-conditions for mp3? #2

Closed mro closed 8 years ago

mro commented 8 years ago

the code from the Readme:

package main

import (
  "github.com/bogem/id3v2"
  "log"
  "os"
)

func main() {
  tag, err := id3v2.Open("file.mp3")
  if err != nil {
    log.Fatal("Error while opening mp3 file: ", err)
  }

  pic := id3v2.NewAttachedPicture()
  pic.SetMimeType("image/jpeg")
  pic.SetDescription("Cover")
  pic.SetPictureType("Cover (front)")

  artwork, err := os.Open("artwork.jpg")
  if err != nil {
    log.Fatal("Error while opening an artwork file: ", err)
  }
  defer artwork.Close()

  if err = pic.SetPictureFromFile(artwork); err != nil {
    log.Fatal("Error while setting a picture from file: ", err)
  }
  if err = tag.SetAttachedPicture(pic); err != nil {
    log.Fatal("Error while setting a picture frame to tag: ", err)
  }

  if err = tag.Flush(); err != nil {
    log.Fatal("Error while closing a tag: ", err)
  }
}

doesn't set the image for e.g. https://raw.githubusercontent.com/mikkyang/id3-go/master/test.mp3 as file.mp3.

n10v commented 8 years ago

It's very strange, because on my computer everything works: 2016-05-28 18 49 06

n10v commented 8 years ago

Updated library. Try to update it: go get -u github.com/bogem/id3v2 It should work

n10v commented 8 years ago

It also works with file.mp3: 2016-05-28 18 51 13

mro commented 8 years ago

let me double check what image I used.

mro commented 8 years ago

Yikes, your update fixed it!

previously it was:

go get -u github.com/bogem/id3v2
curl --output "artwork.jpg" "http://www.br.de/radio/bayern2/wissen/radiowissen/herodes-festung-100~_v-img__16__9__m_-4423061158a17f4152aef84861ed0243214ae6e7.jpg?version=6f858"
curl --output "file.mp3" "https://raw.githubusercontent.com/mikkyang/id3-go/master/test.mp3"
go run issue-2.go

neither iTunes nor QuickLook nor Finder (OS X El Capitan) showed the image running above Go code.

n10v commented 8 years ago

I'm very glad of it :) Stay tuned for new updates. Today or tomorrow it will be new version