Serial-ATA / lofty-rs

Audio metadata library
Apache License 2.0
192 stars 36 forks source link

Invalid reading when record date is presented #452

Closed tramhao closed 2 months ago

tramhao commented 2 months ago

Reproducer

Firstly I would like to thank for this great project. Before lofty, I use several different packages to read tags from different formats. I recently met a problem though.

My code to read tags is: https://github.com/tramhao/termusic/blob/master/lib/src/track.rs

Don't know when this problem happens, but now more than half of my mp3 are not recognized. I read the same file with tageditor and it's all right. The tags are in ID3V2 format. The only difference is, the unsupported file all have record date presented. When I delete this tag in tageditor, save it, it becomes supported all right by lofty. Is it a known bug or my code is wrong? I didn't use this tag in my code actually.

Summary

Passing of ID3V2 with record date tag is not working.

Expected behavior

It should be able to read all tags.

Assets

I cannot upload mp3 files but you can check this with any mp3 files in termusic. Thanks.

tramhao commented 2 months ago

Seem a little bit update: When record date is 4 number it is all right to read by lofty, when record date is 8 digits lofty cannot read it. Wired.

Serial-ATA commented 2 months ago

Hello!

The thing with Lofty is, it will parse timestamps into a Timestamp. This is different from other libraries, which will just return a string.

Timestamp parsing is already setup to handle multiple common encoding errors, but it could be that your file has one I am not aware of. Could you open the file up in a tag editor and send the recording date field here? Or you can email me the asset at serial AT [domain on my profile].

When record date is 4 number it is all right to read by lofty, when record date is 8 digits lofty cannot read it. Wired.

A 4 digit timestamp in ISO 8601 format is just a year, which is perfectly valid (it is the only required field).

tramhao commented 2 months ago

The wrong recording date in tageditor is like this:

20200820

The correctly parsed recording date in tageditor is like this:

2009

Or empty is all right. I sent to you a wrongly parsed mp3 by email.

tramhao commented 2 months ago

By the way, most of my tags were embeded by yt-dlp(ffmpeg underlying). The recording date should be from youtube.

Serial-ATA commented 2 months ago

Yeah, looks like yt-dlp embeds dates incorrectly for some reason. Your date "20200820" should be "2020-08-20". I'll see if I can easily support that format since yt-dlp audio files are pretty popular.

tramhao commented 2 months ago

I confirm that the problem is solved by #453. Thanks.