-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If a mp3 file has no tags at all, the go library reports no tags found #98
Comments
Not quite sure I understand the issue. Can you post an example file and some code so that we can reproduce your issue? Note: the library function The If you're using the library you should get back |
It takes a special file to duplicate it. I have several, but they contain copyrighted music so I do not want to post them. If you run the file against the source built from the github link, you get the error message displayed, it is not trapped ./bugs Sweet_Darlin_Heart.mp3 Run it thru your cmd/tag works as expected, gives a complete error I can share a file with the developers with the understanding that no intention is made to violate the copyright. This program will exercise the issue. The issue is that the library does not return the error, but instead it writes the error message directly to stdout. Source code on github at Send me an email and I'll give you a mp3 file that breaks it |
I wrote a simple program to try this out: package main
import (
"flag"
"log"
"os"
"github.com/dhowden/tag"
)
var path = flag.String("path", "", "`path` to file to check")
func main() {
flag.Parse()
f, err := os.Open(*path)
if err != nil {
log.Fatalf("Could not open: %v", err)
}
m, err := tag.ReadFrom(f)
if err != nil {
log.Fatalf("Error from ReadFrom: %v", err)
}
log.Printf("Tags: %v", m)
} When run it outputs:
Not sure what you mean here:
I only get the output from the At this point I realised I missed that you had also posted an example program (thanks - always easier to reproduce with an example!), so also tried that (with some slight modifications to concentrate on the idea of testing if ReadFrom writes out the error to stdout instead of returning it): package main
import (
"fmt"
"os"
"github.com/dhowden/tag"
)
func main() {
if len(os.Args) == 1 {
fmt.Println("Usage, bugs [filespec]")
return
}
arg := os.Args[1]
if arg == "" {
fmt.Println("PIB, input path empty")
return
}
file, err := os.Open(arg)
if err != nil {
fmt.Printf("err : %v %s\n", err, arg)
return
}
defer file.Close()
m, err := tag.ReadFrom(file)
if err != nil {
// Deliberately don't print anything. If the lilbrary is printing
// the error we should see it.
// fmt.Printf("%v", err)
return
}
if m == nil {
fmt.Printf("tag.ReadFrom (file) turned nil but no error for %s\n", arg)
}
fmt.Println("Got to the end") // Print this if we get to the end
} With this program, I get no output from the example mp3 file which also seems to suggest that $ ./bugs sample.mp3 Can you check that you are using a clean checkout of the library? |
I deleted all the source in my go tree for dhowden and then rebuilt and
rerun my test program
I ran it against the example file that I sent you a link to my dropbox.
I have several files that will fail, but its only about 3 files out of 6,000
I put in the slight changes you had.
// Deliberately don't print anything. If the lilbrary is printing
// the error we should see it.
//fmt.Printf("%v", err)
The library is not printing it with Printf commented out.
My code will print the error if the line is active.
fmt.Printf("%v", err)
So looks like programmer error (mine)
not library bug (yours)
Thanks for helping me debug this.
Thanks
Pat
|
No issue here. User error in calling library. |
Its rare, nearly all mp3 files have some tags, but if there are none, the tag.ReadFrom (file)
will write out
error reading file: no tags found
without returning an error
"github.com/dhowden/tag"
m, err := tag.ReadFrom(file)
If I build the 'tag' executable, and run it on the file, it does give a reasonable error message
tag /home/pfarrell/whome/Music/mp3/CopyHitsForCar/Sweet_Darlin;\ Heart.mp3
error reading file: no tags found
but the go library does not return an error.
Interesting, the message does not have a /n at the end, so its formatted like most fmt.Errorf strings
The text was updated successfully, but these errors were encountered: