Plugin Registration Interoperability - Make a Plugin Optional?

Example: I want to scan for Lyrics as an option, not a constant.

The APISeeds Lyrics plugin is registered as a track metedata processor.

register_track_metadata_processor(ApiseedsLyricsMetadataProcessor().process_metadata)

Can this be changed to register_album_action, register_track_action and be used on demand instead?

Other than just make a change and see what happens, is there anything stopping this from functioning fully?

This should work, I donā€™t see a reason why having this on demand wouldnā€™t work.

The only case I see where a metadata processor cannot directly be replaced by a manual action is when it needs some data that is only available in the original API response from the MB web service. But even this can be easily worked around with a combination of a metadata processor and manual action.

:slight_smile:

Now to figure out why:

E: 08:09:24,248 pluginmanager.plugin_error:181: Plugin 'apiseeds_lyrics_fetch'
Traceback (most recent call last):
  File "picard/pluginmanager.py", line 265, in _load_plugin_from_directory
  File "/Users/tdiaz/Library/Preferences/MusicBrainz/Picard/plugins/apiseeds_lyrics_fetch.zip/apiseeds_lyrics_fetch.py", line 123, in <module>
    register_album_action(ApiseedsLyricsMetadataProcessor())
NameError: name 'register_album_action' is not defined
E: 08:09:39,824 pluginmanager.install_plugin:405: Unable to load plugin 'apiseeds_lyrics_fetch': Failed loading newly installed plugin apiseeds_lyrics_fetch
D: 08:09:39,824 pluginmanager._remove_plugin_files:309: Remove plugin files and dirs : 'apiseeds_lyrics_fetch'
D: 08:09:39,824 pluginmanager._remove_plugin_files:320: Removing file '/Users/tdiaz/Library/Preferences/MusicBrainz/Picard/plugins/apiseeds_lyrics_fetch.zip'

Seems I ran into that before too, when experimenting with Plugins.

register_track_metadata_processor(ApiseedsLyricsMetadataProcessor().process_metadata)
register_options_page(ApiseedsLyricsOptionsPage)
# register_track_metadata_processor(ApiseedsLyricsMetadataProcessor().process_metadata)
register_album_action(ApiseedsLyricsMetadataProcessor().process_metadata)
register_options_page(ApiseedsLyricsOptionsPage)

That should be all it takes? I also changed the name and version # slightly, and even removed the APISeeds lyrics zip that was there, but disabled.

Two things:

  1. You cannot just call register_album_action without importing it first
  2. You cannot simply pass the function that imements a metadata processor to register_album_action. Metadata processors and actions take different parameters, you have to adopt the code to this

Also see how you try to use a track metdata processor as an album action. This cries for code changes. Code meant to manipulate a single track wonā€™t magically work for the album.

1 Like

Dā€™oh!

  1. I told you Iā€™m brute force learning this stuff. ā€œHmmā€¦ Itā€™s already a plugin, it should have what it needsā€ā€¦ (and PyCharm hides the @import functions so I forget to look ā€˜up thereā€™)
  2. I meant track action. Copied & Pasted the wrong line in.

I was just going to be thrilled to see it listed on the plugin menu first.

/me goes back to imploding things.

Traceback (most recent call last):
  File "./picard/ui/itemviews.py", line 517, in contextMenuEvent
    for index in range(1, len(action.MENU) + 1):
AttributeError: 'ApiseedsLyricsMetadataProcessor' object has no attribute 'MENU'
./run: line 5: 21658 Abort trap: 6           python3 tagger.py

Now to see why itā€™s causing the context menu to crashā€¦ Now lets see what else Iā€™m missing / should be changingā€¦ Since itā€™s "a working plugin- there shouldnā€™t be -that- much I need to change.

Sorry if Iā€™m an irritant, Iā€™m not trying to be. Iā€™m just still stuck in the era of ā€œeverything is a single listing of source codeā€.

I really have gotten a lot out of all this mucking around and like how the development version somewhat kind of feels even if just a teeny weeny little bit influenced by a couple of my impromptu changes and thoughtsā€¦

2 Likes

Donā€™t worry about it, people can choose to reply or not based on if they like the question :slight_smile:
Nice to have you here!

1 Like