GithubHelp home page GithubHelp logo

Comments (4)

creeperyang avatar creeperyang commented on June 12, 2024 1

@dvdcxn v1.2 has fixed this, and you can always check stats.version to determine whether the id3 parse worked.

  • If invalid argument passed, the promise rejected.

  • If the buffer is not valid id3v1 or id3v2 buffer, you get {version: false}.

  • Otherwise, you get

    {
       version: {
          v1: false | object,
          v2: false | object
       }
    }

Enjoy the new version.

from id3-parser.

creeperyang avatar creeperyang commented on June 12, 2024

@dvdcxn I think there is no need to change id3-parser's behavior.

You could wrap the lib yourself, such as code below:

function analyseFile(fileName) {
	let _readFile = bluebird.promisify(readFile);
        let content;
	return _readFile(fileName)
                .then(buf => {
                       content = buf;
                       return buf;
                 })
		.then(id3.parse)
		.then(stats => {	
			if(stats.version){	
				return stats;
			}
			else{
				throw `Couldn\'t determine id3 data for file ${fileName}`;
			}		
		})
		.catch(err => {
                    return content;
                });
}

from id3-parser.

chordmemory avatar chordmemory commented on June 12, 2024

@creeperyang Will do. Is checking whether the version is truthy a reliable enough way to determine whether the id3 parse worked?

from id3-parser.

creeperyang avatar creeperyang commented on June 12, 2024

No. If the buffer's length is less than required, false is returned.

// use this instead
if (stats && stats.version) {}

Good question! I should make the promise rejected when the buffer is less than expected.

from id3-parser.

Related Issues (17)

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.