KristoforMaynard / music-tag

Simple interface to edit audio file metadata
MIT License
125 stars 19 forks source link

Year sanitazer fails with values met in the wild #30

Open pyhedgehog opened 2 years ago

pyhedgehog commented 2 years ago

I've got error: ValueError: Could not extract year from: 2014-11-18 15:05:00 I propose following patch to sanitize_year():

if re.match(r'^[0-9]{4}[-\s][0-9]{2}[-\s][0-9]{2}(?:[T\s][0-9]{2}:[0-9]{2}:[0-9]{2})?$', year):

instead of

if re.match(r'^[0-9]{4}[-\s][0-9]{2}[-\s][0-9]{2}$', year):
retiredprogrammer440 commented 1 year ago

I just installed music_tag and the current version still has this issue. Since by definition re.match matches the beginning of the string, I simply remover the $ in the match string. Changed:

re.match(r'^[0-9]{4}[-\s][0-9]{2}[-\s][0-9]{2}$', year):

to:

re.match(r'^[0-9]{4}[-\s][0-9]{2}[-\s][0-9]{2}', year): # Remover $ at end of string

and it worked fine