benrr101 / node-taglib-sharp

A node.js port of mono/taglib-sharp
GNU Lesser General Public License v2.1
42 stars 11 forks source link

Id3v2FrameIdentifier doc and possible bug ? #78

Closed stuartambient closed 1 year ago

stuartambient commented 1 year ago

In this doc

In the constructor parameters this is a typo:

v4 | string | Identifier string to use on ID3v2.4 tags. If not supplied, frame type is not valid for ID3v2.4 tags. v3 | string | Identifier string to use on ID3v2.3 tags. If not supplied, frame type is not valid for ID3v2.4 tags.

However in my code I have `new Id3v2FrameIdentifier("v3")` and when I console.log the frame this is what I'm seeing -

TextInformationFrame {
  _header: Id3v2FrameHeader {
    _frameId: FrameIdentifier {
      _version4: [ByteVector],
      _version3: undefined,
      _version2: undefined
    },
    _frameSize: 0,
    _flags: 0
  },
  _encoding: 3,
  _textFields: []
}

It looks like having the 'v3' identifier is still setting the tag for ID3v2.4 ?

benrr101 commented 1 year ago

Hi, I think you're right that it's a typo: if v3 is falsy, the frame identifier is not valid for ID3v2.3 tags. However, I think you might be using the constructor incorrectly - arguments are the identifier for the frame. For example, if you wanted to create a TIT2 identifier (not recommended for the reason below, but it's just an example), you can do new Id3v2FrameIdentifier("TIT2", "TIY2", undefined). This would indicate the frame is identified as TIT2 on ID3v2.4, TIY2 on ID3v2.3, and isn't supported on ID3v2.2.

However, you probably don't want to be instantiating new frame identifiers unless you plan to create non-standard frames. The list of standard frame identifiers is provided (although probably not properly documented by the auto-documentation tools) as ID3v2FrameIdentifiers export. take a look at the list here https://github.com/benrr101/node-taglib-sharp/blob/develop/src/id3v2/frameIdentifiers.ts#L214

Let me know if you have any other questions.

stuartambient commented 1 year ago

First, should I be adding version 4 tags ? I ask because in a number of tagger apps usually only go to id3v2.3.

Also I am not finding 'TIY2' code. It is not in the frameIdentifiers and I couldn't find a reference to it or other ones that differ from v4 to v3. I'm not noticing any differences in the Id3v2TextInformationFrame doc either.

Right now I'm going through various files in my collection. Many of the .mp3 are 'sandwich tags' and in MP3tag (software) it shows as ID3v2.3(ID3v1 ID3v2.3). Some of the id3v2's have textinformation frames, others not.

One last question - If I am writing v2 tags, v1 tags need to be written as well for backwards compatibility, or would is there a way using the unified approach to write all ?

benrr101 commented 1 year ago

It's up to you whether you want ID3v2.4 tags, but I thought you mentioned in your other question that you wanted to use ID3v2.4 tags. ID3v2.3 is generally more compatible with other apps.

As for TIY2 that was just an constructed example to illustrate that if you create a new FrameIdentifier it can have a different ID for v2, v3, and v4. A real example is the involved people list: it changed from IPL in v2 to IPLS in v3 to TIPL in v4. Another example is the date field which was TDA in v2, TDAT in v3, and removed in v4. You can read more on the ID3 documentation site. It's been mostly down for the past year+, but archive.org has a copy https://web.archive.org/web/20220502230008/https://id3.org/id3v2.4.0-changes

Yes, by default when opening mp3s, both v2 and v1 tags are added to the file in memory. The unified approach will write to both of them (the sandwich tag inherits from CombinedTag which writes to all tags in the collection). Take a look at https://github.com/benrr101/node-taglib-sharp/wiki/03-Default-Tags for an explanation of how default tags work.

stuartambient commented 1 year ago

Great, thank you and your wiki updates , edits are also appreciated.