thebigmunch / audio-metadata

A library for reading and, in the future, writing audio metadata. https://audio-metadata.readthedocs.io/
https://forum.thebigmunch.me
MIT License
53 stars 11 forks source link

KeyError: 'TYER' for ID3v2 Tags #12

Closed wehttvM closed 4 years ago

wehttvM commented 4 years ago

Audio metadata is failing to get year/date from mp3 ID3v2 tags.

Date/TYER/year tag feild is shown in 2 diffrent applications with the same mp3 file. [example 1: mp3 diags] 2020_02_05_10_28_54_MP3_Diags_Unstable [example 1: media info] 2020-02-05 10_09_04-MediaArea net_MediaInfo - E__musix_Artists_$teven Cannon_ 2013-12-27  $teven Can

here is the error when calling for the TYER key. 2020-02-05 10_08_24-PowerShell 6 (x64)

the TYER/Date field doesn't print with the ID3v2 tags. 2020-02-05 10_09_51-PowerShell 6 (x64)

thebigmunch commented 4 years ago

Would you be able to post a link or attach the file here or send it via email so I can check it out?

thebigmunch commented 4 years ago

But I can already tell you that the format of TYER is supposed to be a 4 character string of the year, not a full date. So, those programs and that tag value are ignoring/violating the spec. But, audio-metadata should've raised a ValueError.

thebigmunch commented 4 years ago

But, audio-metadata should've raised a ValueError.

Ah, right. I made it lenient so the ValueError from an invalid frame value will just cause that frame to be ignored rather than just exploding.

thebigmunch commented 4 years ago

So, the TL/DR is that this is working as expected. The value given for the TYER frame violates the ID3v2.3 spec. If you want to use the date like that, you could change the TYER frame to just contain the year and add a TDAT frame to contain the month and day in the MMDD format according to spec. Or, you could upgrade them to ID3v2.4, where the equivalent TDRC frame supports that value.

wehttvM commented 4 years ago

Understood, I was under the impression that it would just work out of the box. I never looked through the ID3 spec before. Ok, thanks I'm going to close the issue.

thebigmunch commented 4 years ago

Right now, I'm being strict about sticking to specifications. This is in large part to wanting to find all the wonky oddities out there. In the future, I do want to support fixing or, at least, reporting compliance issues like this which would mean audio-metadata would have a way for these to load with that info in some way to be corrected. But, that probably wouldn't come until after I get around to adding MP4 support and write support for the formats at that point. Still pondering what that would/should look like.

Thanks for the interest and report, though. Most of my own music collection is FLAC, so I don't really get a chance to see examples of other formats from the wild unless people report them to me.

wehttvM commented 4 years ago

I am right there with you on being strict towards the ID3v2 spec, and, yes, most of my collection is in FLAC too. I think it is rational to think that not everyone, like myself, will have tags that conform to ID3, so I believe it is important to allow reading of those frames. It would also be helpful to set a warning of some sort that the tags are non-compliant. I am excited to see where this project is headed in the aspect of writing compliant tags, because, from my knowledge, there are not many useful and helpful python based tools to do this.

thebigmunch commented 4 years ago

So, while I was going through testing ignoring frames not compliant with the ID3v2 version, I noticed this file also had an empty TYER frame. Out of curiosity, do you know what software was used to create/edit this file?