polyfloyd / rust-id3

A rust library for reading and writing ID3 metadata
MIT License
245 stars 47 forks source link

ID3v1 genre for ID3v2 files #88

Closed martpie closed 2 years ago

martpie commented 2 years ago

Hello 👋

Example file

Screenshot 2022-05-27 at 11 12 25

It would seem some files can still use the "genre ID" type of genre even for id3v2.3 files, but between parenthesis. I checked how other libraries were doing it, and it would seem they parse genres by checking if parenthesis exist: https://github.com/Borewit/music-metadata/blob/1e1bd78dc5abeea49dfe0402681f39da64aa60b4/lib/id3v2/FrameParser.ts#L26-L70

polyfloyd commented 2 years ago

Checked the spec and this behaviour actually seems to be documented:

TCON

The 'Content type', which previously was stored as a one byte numeric value only, is now a numeric string. You may use one or several of the types as ID3v1.1 did or, since the category list would be impossible to maintain with accurate and up to date categories, define your own.

References to the ID3v1 genres can be made by, as first byte, enter "(" followed by a number from the genres list (appendix A) and ended with a ")" character. This is optionally followed by a refinement, e.g. "(21)" or "(4)Eurodisco". Several references can be made in the same frame, e.g. "(51)(39)". If the refinement should begin with a "(" character it should be replaced with "((", e.g. "((I can figure out any genre)" or "(55)((I think...)". The following new content types is defined in ID3v2 and is implemented in the same way as the numerig content types, e.g. "(RX)".

RX    Remix
CR    Cover