beetbox / mediafile

elegant audio file tagging
http://mediafile.readthedocs.io/
MIT License
100 stars 26 forks source link

Empty fields returning None #38

Closed jtpavlock closed 4 years ago

jtpavlock commented 4 years ago

Going off the docs.

MediaFile attempts to always return a usable value (i.e., it never returns None or throws an exception when a tag is accessed). If a tag is not present, an empty and false value of the appropriate type – such as zero or the empty string – is returned.

>>> f = MediaFile('tests/resources/audio_files/empty.mp3')
>>> print(f.title)
None

Is this going against expected behavior or maybe the docs are out of date?

sampsyo commented 4 years ago

That's a good point—this did change in https://github.com/beetbox/beets/pull/660, and it also looks like the docstring for _safe_cast is out of date. Fields can now return None if the tag is missing altogether, which is useful for some clients.