From: Nick Bowler Date: Fri, 1 May 2020 23:55:41 +0000 (-0400) Subject: karaoke-flagger: Don't break on stanadlone recordings. X-Git-Url: https://git.draconx.ca/gitweb/picard-plugins.git/commitdiff_plain/4712c6feea4ab43b26956c35338a2b0038a17b6c karaoke-flagger: Don't break on stanadlone recordings. When standalone recordings are loaded into Picard, the "track" metadata processor is called with a "track" parameter that is not actually a track at all, but a recording. We actually only care about the recording so assume it is the recording if it lacks the "recording" key. --- diff --git a/karaoke-flagger.py b/karaoke-flagger.py index 13abe78..11c327e 100644 --- a/karaoke-flagger.py +++ b/karaoke-flagger.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright © 2019 Nick Bowler +# Copyright © 2019-2020 Nick Bowler # # License GPLv3+: GNU General Public License version 3 or any later version. # This is free software: you are free to change and redistribute it. @@ -17,7 +17,7 @@ karaoke tracks, and left unset otherwise. So a tagger script might use $if(%_karaoke%,$set(comment:karaoke,%_karaoke%)), for example, to embed that into the file's comment tag.

''' -PLUGIN_VERSION = "0" +PLUGIN_VERSION = "1" PLUGIN_API_VERSIONS = ["2.0"] PLUGIN_LICENSE = "GPL-3.0-or-later" @@ -28,7 +28,9 @@ def modulename(): return modulename.__module__[len("picard.plugins."):] def add_metadata(tagger, metadata, track, release): - for r in track["recording"]["relations"]: + # for stanadlone recordings, "track" is actually a recording, not a track + recording = track.get("recording", track) + for r in recording["relations"]: # 'karaoke version of' is the backward relation of this type... if r["type-id"] != "39a08d0e-26e4-44fb-ae19-906f5fe9435d": continue