]> git.draconx.ca Git - picard-plugins.git/commitdiff
karaoke-flagger: Don't break on stanadlone recordings.
authorNick Bowler <nbowler@draconx.ca>
Fri, 1 May 2020 23:55:41 +0000 (19:55 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sun, 3 May 2020 01:58:37 +0000 (21:58 -0400)
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.

karaoke-flagger.py

index 13abe78b22a6a8023d7e1b2aaaf8ae1de9904a43..11c327ee16e2801c71873a22ee55bc874e101e2d 100644 (file)
@@ -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
 <code>$if(%_karaoke%,$set(comment:karaoke,%_karaoke%))</code>, for example,
 to embed that into the file's comment tag.</p>
 '''
-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