node-id3 icon indicating copy to clipboard operation
node-id3 copied to clipboard

'Genre' field parsed inconsistently when there are multiple values

Open mxro opened this issue 10 months ago • 5 comments

Thanks for this great library!

I have a number of files that have more than one value for the 'Genre' field. This is rendered inconsistently - sometimes with a ; character between the genres and sometimes with no character between them at all.

This it is how the Genre field for a particular track is rendered in MusicBee:

Image

This it is how it is displayed in MP3Tag

Image

And this is what node-id3 reads when using NodeID3.read(filePath);:

"TCON": "Hip Hop10sRated-4List-The DriveList-The WorkList-High PowerList-Sadness",
 "genre": "Hip Hop10sRated-4List-The DriveList-The WorkList-High PowerList-Sadness",

In order to check if JSON.stringify() masks any 'strange' characters, such as NULL, I have implemented the following method to verify the separation character is not in the genre.

export function printGenreMetadata(genre: string): string {
  if (!genre) return '';

  return Array.from(genre).map(char => {
    if (char.charCodeAt(0) <= 127) {
      return char;
    }
    return `{${char.charCodeAt(0)}}`;
  }).join('');
}

This yields the same string:

Hip Hop10sRated-4List-The DriveList-The WorkList-High PowerList-Sadness

It seems like the field is only calculated correctly if there are ; characters between the genres. Such as for the following track, that returns a matching string to what is displayed in MP3tag:

Image

mxro avatar Mar 23 '25 07:03 mxro