aadsm / JavaScript-ID3-Reader

ID3 tags reader in JavaScript (ID3v1, ID3v2 and AAC)

Home Page:http://www.aadsm.net/libraries/id3/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ideas about a rewrite

icidasset opened this issue · comments

Hey, so I was thinking of doing a rewrite.
My biggest issues were:

  • Global variables all over the place
  • Cannot be used in web workers
  • Code is not easy to read
  • IEBinary_getByteAt
  • Data is stored in memory (I think this should be handled by the user)

I would like to rewrite this using es6 modules/syntax, es6 classes and typed arrays (I don't know much about this though). The es6 classes I would use for the binaryFile, so it's easy to extend and understand.

Now, like I said, I don't know much about this whole thing, but I do want to learn. I wrote down a rough idea about how I think this library works: https://gist.github.com/icidasset/c6d972c90a2d2f0565b1 Please let me know if I'm on the right track with this thing.

Thank you for starting this.
Completely agree with the first 3 points and that's the reason I started rewriting this lib last year. Unfortunately I haven't had the time this year to continue with the project but it seems that now is a good opportunity to look at it again.

We have pretty similar goals here, my main goals are:

  • Better API
  • Readable code (it's pretty shitty atm)
  • Node compatible
  • Unit tests

To be node compatible I've decided to use CommonJS instead of IE6 modules. When it comes to organization they pretty much do the same.
My plan is to use browserify to compile the CommonJS into browser. Jessie did an amazing job with this here: #51
It's similar to what I had in my new project but even better. I'm planning to land his changes this weekend (just need to make a few changes) and hopefully start a new project with the code I already have. We can continue the discussion from there.

You're welcome 😄

Alright, sounds good. I didn't see that PR yet, that's awesome! Let me know when I can help.

Question: Is it necessary to do the HEAD request? Because, when you request the first 7 bytes for the format-id, you get this in the response headers:

Content-Length:4096
Content-Range:bytes 0-4095/5961504

5961504 being the total content-length, which is the only thing we need from doing the HEAD request, right?

Yeah, that's a good point. Not sure if all server implementations return that info but definitely something that is easily detectable.

I've just committed that PR after a few modifications.
I'm preparing the initial commit for the new repo, but still need to plugin babel so I can use ES6.
I've run out of time this weekend but will continue next weekend and hope to make the first commit by then. The current code structure I have is:

  • MediaFileReader: defines the interface to read files (from FS or HTTP)
    • NodeFileReader: reads files from node fs
  • MediaTagReader: defines the interface to read tags from files.
    • ID3v2TagReader: reads ID3v2 tags
    • ID3v1TagReader: reads ID3v1 tags

I also have jest tests for these classes.

Awesome, thanks for making time to do this 👍
The code structure sounds great.

Here's the initial commit, still quite a bit to go but the API is kind of settled down. https://github.com/aadsm/jsmediatags Will continue this issue over there.