nicfit / eyeD3

eyeD3 is a Python module and command line program for processing ID3 tags. Information about mp3 files (i.e bit rate, sample frequency, play time, etc.) is also provided. The formats supported are ID3v1 (1.0/1.1) and ID3v2 (2.3/2.4).
http://eyed3.nicfit.net/
GNU General Public License v3.0
541 stars 58 forks source link

Trying to get full date, but TDAT DateFrame shows up empty. #542

Closed PlaylistsTrance closed 3 years ago

PlaylistsTrance commented 3 years ago

I'm running version 0.9.6. I'm having an issue where I want to read the full YYYY-MM-DD date from an mp3 file. mp3tag shows it has a year tag and a MMDD value in the date tag (e.g. 2105), but when using .getBestDate() only the year shows up in the string for some files. I checked the frame set of the eyed3 tag object for one of the affected files, and it does have a b'TDAT': [<eyed3.id3.frames.DateFrame object at 0x0000016724B5C5F8>] field, but print(t._getDate(b"TDAT")) returns an empty string (as well as print(t.frame_set[b"TDAT"][0].text.encode('latin1')). The affected mp3 files use ID3v2.3, but so do the large majority of unaffected ones. About 30% of files that have a TDAT field return an empty date. Any idea about what's causing this problem?

nicfit commented 3 years ago

Hi @PlaylistsTrance , can you send me file to test with. If copyright is an issue check out the 'extract' plugin for eyeD3. e.g. eyeD3 -P extract ./sample.mp3 -o sample.id3

PlaylistsTrance commented 3 years ago

Yeah, here's one: https://drive.google.com/file/d/1ETIzKQH3JRvfGdB8FwX6I26silxE4qx7/view

nicfit commented 3 years ago

ID3 dates are a mess esp. in v2.3, which is what you have here. eyeD3 tries, sometimes getting in the way, to make life better and also bridge the differences with ID v2.4 which dropped ALL the v2.3 frames. So, eyeD3 -l debug and hexdump -C are the tools here...

In this v2.3 tag you provided there are two date frames: TDAT and TYER. TDAT is an empty frame, contains no data. TYER is the value "2018". TYER is just that, a year and TDAT is the MMDD component. The warning occurs when assembling the two that were provided, but TDAT being empty ends up being "2018--", and invalid.

eyed3.id3.tag:WARNING: Invalid v2.3 TYER, TDAT, or TIME frame: Invalid date string: 2018--

Digging into the file confirms empty TDAT: image

PlaylistsTrance commented 3 years ago

Thanks for responding. Hm, if that's the case then why is the Python taglib module able to retrieve the full date, as well as mp3tag showing 0905 in the DATE field? With eyed3:

>>> import eyed3
>>> m1 = eyed3.load(r"D:\Music\Music\K-Pop\Yerin Baek\[2019.05.09] A-TEEN2 Part.1\1. Lean On Me.mp3").tag
Invalid date: 0905
>>> m1.getBestDate()
<eyed3.core.Date object at 0x0000022EBC959748>
Invalid v2.3 TYER, TDAT, or TIME frame: Invalid date string: 2019--

With taglib:

>>> import taglib
>>> m2 = taglib.File(r"D:\Music\Music\K-Pop\Yerin Baek\[2019.05.09] A-TEEN2 Part.1\1. Lean On Me.mp3").tags
>>> m2["DATE"]
['2019-05-09']

(This is a different file than the one I shared originally, but it's the same problem.) I should have mentioned that loading the problematic files prints the "Invalid date" log messages. I assumed it did that for every file with a DATE tag for some reason.

PlaylistsTrance commented 3 years ago

https://drive.google.com/file/d/10pp4DYIEvMZzuRoDXIPT57DVDPC_XwKl/view?usp=sharing Here's a silent mp3 with the same tags as that Yerin Baek track. I checked with both taglib and ffprobe, both are able to read the date field correctly. eyed3 says the date is invalid and is only able to show the year in getBestDate(). Could you please look into it again?