Plugin updates for Picard 2.0

A couple of plugins have received important updates for Picard 2.0. Picard 2.0 introduced fundamental changes, which meant all plugins needed to be updated to being compatible for Picard 2.0. Most plugins were, but unfortunately some plugins just got under the wheels. So a few days ago I went looking over all plugins and fix the most pressing issues. Here is a some summary of what changed:

fanart.tv cover art 1.4
This one had a stupid bug in the Picard 2 version that caused it to not submit proper API credentials to fanart.tv, thus never returning any data. My fault, sorry.

Last.fm 0.7
Yes, the Last.fm plugin is back from the dead! This plugin already stopped working for Picard 1 when Last.fm introduced breaking changes to their API. There was some attempt to update the plugin, but then Picard 2 happened and this got stalled. Anyway, it is back again for Picard 2. It even got a new feature and now optionally allows regular expressions for excluding tags.

Last.fm.Plus was removed
Unfortunately this plugin is gone for now and was removed from the plugin list. It also needs updates for Picard 2 and Last.fm API 2.0, but unless somebody is willing to do these updates and to maintain this plugin (I won’t) it is now officially dead. IMHO this plugins UI and code are too cluttered and overloaded. I’d rather add important functionality from this plugin to the standard Last.fm plugin. And if for you the standard Last.fm plugin doesn’t have enough features I’d recommend using the Last.fm.ng Plugin.

No release
The no release plugin, which allows you to remove any release specific information from a release, needed updates for Picard 2.0. This is now done.

Going forward I want to tackle a few more issues with existing plugins to improve the overall plugin quality. Currently on my list is the “Musixmatch Lyrics”, which blocks the UI while it is loading data, and reviewing the AcousticBrainz and Wikidata plugins, since those where reported to cause crashes and loading issues. For Wikidata there is already work in progress. Also I would like to get the Classical Extras plugin by @MetaTunes into the official plugin page.

9 Likes

I just updated Picard to 2.0.4 and updated most of the plugins, too. However, I can’t install the last.fm plugin at all. Nothing happens when I hit the install button. I’ll see if I can get it done manually.

Edit: No luck with manual install from the included .zip file. Even tried switching out the files for the latest online.

Edit again: I had a bunch of stuff left on my computer from the switch between Program Files (x86) and Program Files. So I saved the settings, removed everything, and reinstalled. Then it installed ok. The only one not working now is BPM.

I made a report here: https://github.com/metabrainz/picard-plugins/issues/163

1 Like

The BPM plugin does not support Windows. Please see https://tickets.metabrainz.org/browse/PICARD-1335 and related issues.

2 Likes

Gotcha, thanks. I’ll vote for those.

1 Like

Trying to make this work, no luck so far. Installed the plugin, it shows up in plugin tab properly, even the sub-menu is there. However, it doesn’t add the Genre tag to any tested popular releases. When I ticked “Use artists tag” option, I get a following error:
E: 21:49:30,695 C:\Users\furma\AppData\Local\MusicBrainz\Picard\plugins\lastfm.zip\lastfm_init_._tags_downloaded:123: Problem processing download tags

Traceback (most recent call last):

File "C:\Users\furma\AppData\Local\MusicBrainz\Picard\plugins\lastfm.zip\lastfm_init_.py", line 109, in _tags_downloaded

if not matches_ignored(ignore, name):

File "C:\Users\furma\AppData\Local\MusicBrainz\Picard\plugins\lastfm.zip\lastfm_init_.py", line 63, in matches_ignored

if isinstance(pattern, re.Pattern):

AttributeError: module ‘re’ has no attribute ‘Pattern’

Anyone else getting this? I am on Picard 2.0.4. windows version. Plugins: featartistsintitles, lastfm, no_release, release_type, standardise_feat

1 Like

Sorry for that, I just realized the code is incompatible with anything below Python 3.7, and the Picard Windows version currently ships with Python 3.6. I will provide a fixed version.

1 Like

Thank you for your work on these. I have been struggling with the genre tag since 2.0 was released, so I am glad that these plugins are being looked into.

2 Likes

The fix was deployed, lastfm plugin version 0.8

4 Likes

@outsidecontext I know you are busy with the plugins you listed and your other work on Picard (which is greatly appreciated, btw!) but I was wondering, could find some time to port the plugin “Smart Title Case” to api v2? It’s pretty much the only important plugin that I use that hasn’t been ported yet. Thanks a lot!

@culinko, please have a look at https://github.com/rdswift/picard-plugins/raw/2.0_working/plugins/smart_title_case/smart_title_case.py and see if it works for you. It’s a quick hack, but if it works I’ll clean it up and submit it formally. Thanks.

3 Likes

Great job! The plugin works without any errors and I haven’t been able to find any issues so far.

1 Like

Thanks for letting me know. I hate to admit it, but I didn’t test it thoroughly here before turning you loose on it. I’ll have to wait until tomorrow to clean it up and submit it. I just got back from an eye examination and I can barely see because of the drops in my eyes.

2 Likes

@rdswift Hi, I just found a bug in the Smart Title Case plugin. I’m not sure if it was already present before you ported it to the v2 api, though. Could you look at it if you get some time, please? Below is the bug description and reproduction steps:

The following tags are affected: artists, ~albumartists
The following are some examples of affected artists: Armin van Buuren, Sharon den Adel, Hayley Williams of Paramore, blink-182

These artists are being changed into stuff such as “<map object at 0x0000000005837E80>”

Here is an example release where such behavior occurs when your load it into Picard: Release “In and Out of Love” by Armin van Buuren feat. Sharon den Adel - MusicBrainz

Here is a screenshot of said release loaded into Picard:

I used the following script to show the albumartists tag: $setmulti(albumartists,%_albumartists%)

Thank you so much for looking at this issue, much appreciated!

Please download the updated file from my repository on GitHub and let me know if this corrects the problem. If so, I’ll submit a pull request to update the master files used by Picard. Thanks.

1 Like

The issue is now fixed, I re-tested all of the affected tracks that gave me the error before. You are amazing, thank you so much!

Once I had a chance to look at it, the fix was pretty simple (adding 6 characters to a single line of existing code). Nothing amazing in that. :wink:

1 Like

I’m highjacking this threat and hope this is ok. I used a plugin with picard 1.42 to generate title sort tags. I don’t remember where I got it from. Now I changed to Picard 2.3.2 and obviously the plugin is not working anymore. Sadly I have no idea how to update the old plugin to work with the new api.
Could someone help me with it please. Just changing the api numbers in not doing the job.

PLUGIN_NAME = 'Title sort names'
PLUGIN_AUTHOR = 'Jacob Rask'
PLUGIN_DESCRIPTION = 'Guesses title and album sortnames (language specific) and adds as titlesort and albumsort tags.'
PLUGIN_VERSION = "0.1.4"
PLUGIN_API_VERSIONS = ["0.12", "0.15"]

from picard.metadata import register_track_metadata_processor
from picard.metadata import register_album_metadata_processor
import re

# define articles
_articles = {}
_articles['deu'] = ['Der ', 'Das ', 'Die ', 'Eine? '] # German
_articles['eng'] = ['Th[ae] ', 'Da ', 'An? '] # English
_articles['esp'] = ['El ', 'La ', 'L[ao]s ', 'Una? ', 'Un[ao]s '] # Spanish
_articles['fra'] = ["Les? ", "La ", "L'", "Une? ", "Des "] # French
_articles['ita'] = ["Il ", "L[aeo] ", "L'", "I ", "Gli ", "Un[ao]? ", "Un'"] # Italian
_articles['swe'] = ['De[nt]? ', 'Dom ', 'E(n|tt) '] # Swedish

# compile sort language regular expressions
_re_articles = {}
_regmul = ''
for lang, a in _articles.iteritems():
    reg = ''
    for i in range(len(a)):
        reg = '|^' + _articles[lang][i] + reg
        _re_articles[lang] = re.compile(reg[1:])
    _regmul = _regmul + reg
# all articles are collected and used for "multiple languages"
_re_articles['mul'] = re.compile(_regmul[1:])

def make_sorttitle(title, lang):
    if lang not in _re_articles:
        lang = "mul"
    sort_re = _re_articles[lang]
    match = sort_re.match(title)
    titlesort = title
    if match:
        sort_prefix = match.group().strip()
        titlesort = sort_re.sub("", title).strip() + ", " + sort_prefix
        titlesort = titlesort[0].upper() + titlesort[1:] # capitalize first letter
    return titlesort

def add_titlesort(tagger, metadata, release, track):
    if metadata["titlesort"]:
        titlesort = metadata["titlesort"]
    else:
        titlesort = metadata["title"]
    metadata["titlesort"] = make_sorttitle(titlesort, metadata["language"])

def add_albumsort(tagger, metadata, release):
    if metadata["albumsort"]:
        titlesort = metadata["albumsort"]
    else:
        titlesort = metadata["album"]
    metadata["albumsort"] = make_sorttitle(titlesort, metadata["language"])

register_track_metadata_processor(add_titlesort)
register_album_metadata_processor(add_albumsort)

Picard 2 uses Python 3 so you need to change the line that says

for lang, a in _articles.iteritems():

to

for lang, a in _articles.items():
2 Likes