I am modifying a plugin and I need to check for the existence of a custom tag that the plugin creates. This way I can skip tracks that have already been processed. The plugin grabs an “item” from lib.items(query). In the item it creates a tag called recording_year. I have tried:
if u’recording_year’ in item:
if u’recording_year’ in item.keys():
Both options do not skip already processed files. What is the proper method to check for the existence of the custom field?
Huh, that should do it (even the first, simpler version). Can you maybe try printing out
list(item.keys()) or perhaps even
item.get('recording_year') to confirm that those items don’t actually have the field?
You’re right, the field isn’t populated. I can open the file in a tag editor and see the tag, but according to beets it isn’t there. The plugin is here: https://github.com/phirestalker/beets-recordingdate or at least my copy of it. So if it is sucessfully adding the field to the file, why isn’t beets seeing the field?
EDIT: I did a beet update and now it is working as it should.
So, the question then becomes, how should the plugin force an update of each item in the beets database?
OK. I added item.store() after the item.write() and that seems to be updating that track in the database. Can you do me a huge favor and look over the plugin?
For some reason it seems to be hitting the internet even though as far as I can tell the code to skip tracks comes before the code to query the musicbrainz server.