-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply tag-changing plugins before the change is displayed. #872
Comments
This would definitely be a usability enhancement. I'm not 100% clear where these plugins should interpose (I think they'd need to modify candidates from the data sources directly), but I'm sure we can design something worthwhile. Can we make a list of plugins that work like this? Is it just |
.. and |
|
And the |
Well, currently, |
Is there any update on this? I would love to rewrite some tags with a plugin tapping into the "write" event and seeing the "real" changes reflected in the output would be really cool. |
I have added a few lines to the code (17d87cc), which would solve this for me: With those lines, plugins could tap into the events |
@m-urban Seems good to me! Can you please add documentation for these new events? It would also be really helpful to examine which existing plugins should use the new hooks. |
Right now, this is more a proof of concept, really. There's a couple pitfalls:
Other than that, it appears possible to have plugins, such as |
Ah! Good points all. Maybe we should start a branch to start hacking on this in more detail. For example, maybe we should emit the vents from I'm not quite sure I understand the second bullet—what's currently tricky about manipulating those objects? They are in need of a redesign (they should be more like ordinary dictionaries rather than objects with long lists of fields) anyway, so we could use this change as an excuse to do that now. Multiple handlers is a very good point, related to #1463. I have no immediate solution. I'm not overly worried about the potential inefficiency, but we could consider somehow moving the event emission to after the scoring is complete. |
Initially I planned to emit the events from within the Regarding my second point: The |
I think that's OK—since objects are accessed by reference in Python, and never copied unless explicitly requested, multiple handlers should all see and mutate the same data. |
If |
Since the threading in the importer is pipelined, only one task at a time is in any given state. So, in particular, a single Info object will only be touched in one thread at a time, so plugins will see the objects in sequence. |
Thank you, for clarifying threading - sounds well designed, so this will not become an issue here. I have just committed 69088e4, which moves the proposed events to the There's one more thought: If, for instance, I want to rewrite the title of every track I import, a later |
This looks like it's on the right track! I agree that doing this in the hooks infrastructure will affect Sorry for not being able to figure this out from the GitHub interface, but are these commits on a branch? If so, we can start putting together the documentation and such there. |
I've forked the repo, there's a branch here: tag-change-hook. There isn't much going on there other than the changes you've just seen, but I can add some documentation and update the changelog as well. That way, people could start making use of this infrastructure already. As I am not using the way above mentioned |
Looks great. I'm all for merging the additional events even before we figure out how to apply them to the existing plugins. |
Great, I've created a PR #1499 |
I don't know what the final decision was, but moving the event emission to after the scoring looks counter-productive to me. When updating tags like when |
Sure, I could definitely buy that some metadata changes want to affect scores and others do not. |
Currently it seems that plugins which change the tag values (such as the zero plugin) happen after the tag deltas have been displayed to the user.
So this means that beets will sometimes report a change when there is none.
For example I use the zero plugin to clear the albumartist tag when it would otherwise be set to 'various artists'. Unfortunately, this means that when the 'mbsync' plugin runs, it sees that the old value is '' and the "new" value (from musicbrainz) is 'various artists', and beets displays a change for every VA track.
It seems like the flow should go:
old values→new value lookup→tag rewriting→display changes → save changes
whereas it is currently
old values→ new value lookup→display changes→tag rewriting → save changes.
Not sure if the tag change display is specific to the mbsync plugin or if this a general flow (and would therefore apply to 'beet update' as well)
The text was updated successfully, but these errors were encountered: