Giter Club home page Giter Club logo

Comments (5)

dhowden avatar dhowden commented on August 23, 2024

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 ReadFrom returns the error (https://github.com/dhowden/tag/blob/master/tag.go#L25 ErrNoTagsFound) here: https://github.com/dhowden/tag/blob/master/tag.go#L61.

The tag tool is printing the returned error (in your case ErrNoTagsFound) with some context and a trailing newline here: https://github.com/dhowden/tag/blob/master/cmd/tag/main.go#L48.

If you're using the library you should get back ErrNoTagsFound, not the extended form printed out by the tag tool.

from tag.

pfarrell51 avatar pfarrell51 commented on August 23, 2024

It takes a special file to duplicate it. I have several, but they contain copyrighted music so I do not want to post them.
The file is an MP3 file with no tags in it. I don't know how it was created.

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
no tags found

Run it thru your cmd/tag works as expected, gives a complete error
$ tag -raw Sweet_Darlin_Heart.mp3
error reading file: no tags found

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
https://github.com/pfarrell51/gows/blob/master/music/tagtool/bugs/main.go
This is a simple, 35 line program with error traps. Under 5 lines actually reproducing the issue

Send me an email and I'll give you a mp3 file that breaks it

from tag.

dhowden avatar dhowden commented on August 23, 2024

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:

$ ./check-single -path example.mp3
2023/03/15 19:22:44 Error from ReadFrom: no tags found

Not sure what you mean here:

The issue is that the library does not return the error, but instead it writes the error message directly to stdout.

I only get the output from the log.Fatalf("Error from ReadFrom: %v", err) statement, I don't see two no tags found messages (one written out by the ReadFrom, and one from the log stmt).

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 ReadFrom is passing the error back, not writing it out to stdout:

$ ./bugs sample.mp3

Can you check that you are using a clean checkout of the library?

from tag.

pfarrell51 avatar pfarrell51 commented on August 23, 2024

from tag.

pfarrell51 avatar pfarrell51 commented on August 23, 2024

No issue here. User error in calling library.

from tag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.