Make MediaFile extendable - #644
Conversation
|
Great idea, and a great replacement for the old plugin API that we removed recently that did this in a less-good way. One question: it seems to me like the I think the imperative interface (set then save) is useful in enough scenarios that it's worth keeping. (Especially if we follow the plan to eventually spin it off as a reusable library.) But keeping the new |
|
Some issues came up in #608.
The same happens for genres. Maybe a better approach would be to cache all initial values and compare them when we want to write the file. As for performance issues: Mutagen already caches all tags, so the comparison only strains the cpu and memory. But those are incredibly cheap compared to writing to disk.
This is not solved by the cache above and leads me to think, that the mediafile layer is not the right place to solve this at all. The logic should be contained in mutagen, which can make a byte for byte comparison. I’ll have a look that this and maybe open a PR in their project. |
The test show that we can replace the hard-coded `ITEM_KEYS_WRITABLE` constant with the computed value derived from `MediaField.fields()` and ITEM_KEYS. This will be done in the next commit.
See 65d64a7 why this is possible.
This new property controls which fields to read from a media file.
|
All good points. To argue against myself for a moment, it's possible that these issues are unimportant: for example, it could actually be desirable that beets doesn't fiddle with your existing non-standard ReplayGain tags if you don't change their represented values. But this is one reason why it's important to keep One possible alternative: we could move the dirty tracking to BTW, this is refactoring is getting nicer and nicer. I really like the removal of the duplicate information that lets us rid ourselves of some constants in library.py. Totally awesome! ✨ |
|
Ok, I think I have to concede—once again. This "lazy write" business needs thorough inspection. I also realized the mixing property setters and the The rest should be alright from a feature perspective. If we can't find any more bugs this should be ready to merge. |
Backported from #607. See #607 (comment) This will be return in #644.
|
It looks awesome; I really like this direction and the simplification it brings to the various field lists we used to have. Great insight here! In the mean time, I'll also make a note to try adding as-needed writes in |
This will allow plugins to write and read custom tags and synchronize them with the database as requested in #572 and #637. Coincidentally, this can also solve geigerzaehler/beets-check#1 and (to some extend) #608.
TODO