Persistence of custom plugin state? #4817
-
I can't find any documentation or example plugins that do this, so if the answer is obvious, I apologize in advance. I'm thinking about writing a plugin that needs to persist some custom state (musicbrainz ids that are determined based on a combination of API calls and beets library queries). It does not make sense to extend the beets db models for this purpose - it is plugin-specific state that does not pertain to existing library items or albums. What is considered best practice for storage and retrieval of this kind of data? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We actually do not have a general-purpose way to do this! It's common to attach attributes to items or albums for plugin-specific reasons, but we don't have a way that's unattached to the models. You might consider taking inspiration from the way the importer saves its progress state, which is just storing a pickled data structure in the configuration directory: Lines 69 to 91 in 0c3f428 |
Beta Was this translation helpful? Give feedback.
We actually do not have a general-purpose way to do this! It's common to attach attributes to items or albums for plugin-specific reasons, but we don't have a way that's unattached to the models.
You might consider taking inspiration from the way the importer saves its progress state, which is just storing a pickled data structure in the configuration directory:
beets/beets/importer.py
Lines 69 to 91 in 0c3f428