]> git.draconx.ca Git - picard-plugins.git/commitdiff
karaoke-flagger: Enhance to also flag drama tracks.
authorNick Bowler <nbowler@draconx.ca>
Thu, 14 May 2020 00:58:32 +0000 (20:58 -0400)
committerNick Bowler <nbowler@draconx.ca>
Thu, 14 May 2020 01:06:03 +0000 (21:06 -0400)
Seems like a good fit for this plugin to flag drama tracks based on
work relationships just like we currently flag karaoke tracks based on
recording relationships.

As this is now the karaoke (plus other stuff) flagger plugin, tweak the
plugin name accordingly.

karaoke-flagger.py

index 11c327ee16e2801c71873a22ee55bc874e101e2d..a16c94c08e2b26b8a91397f0aee803b83521b7a1 100644 (file)
@@ -6,18 +6,25 @@
 # This is free software: you are free to change and redistribute it.
 # There is NO WARRANTY, to the extent permitted by law.
 
-PLUGIN_NAME = u"Karaoke Flagger"
+PLUGIN_NAME = u"Karaoke+ Flagger"
 PLUGIN_AUTHOR = u"Nick Bowler"
-PLUGIN_DESCRIPTION = u'''<p>This plugin sets a metadata variable for recordings
-with the "karaoke version of" relation, so that tagger scripts can incorporate
-this fact into file tags.</p>
+PLUGIN_DESCRIPTION = u'''<p>This plugin sets metadata variables for
+certain types of recordings, so that tagger scripts can incoporate
+what sort of track we are looking at into the file tags.</p>
 
-<p>The metadata variable <code>%_karaoke%</code> will be set to "yes" on
-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>
+<dl>
+<dt><code>%_karaoke%</code></dt>
+<dd>Set to "yes" if the track is a karaoke recording.</dd>
+<dt><code>%_drama%</code></dt>
+<dd>Set to "yes" if the track is a recording of an audio drama.</dd>
+</dl>
+
+<p>For example, you could use a tagger script such as
+<code>$if(%_karaoke%,$set(comment:karaoke,%_karaoke%))</code>
+to tag karaoke tracks as such in order to help generate playlists
+for your next karaoke dance party.</p>
 '''
-PLUGIN_VERSION = "1"
+PLUGIN_VERSION = "2"
 PLUGIN_API_VERSIONS = ["2.0"]
 PLUGIN_LICENSE = "GPL-3.0-or-later"
 
@@ -32,11 +39,12 @@ def add_metadata(tagger, metadata, track, release):
     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
-        if r["direction"] == "backward":
-            metadata["~karaoke"] = "yes"
-            return
+        if r["type-id"] == "39a08d0e-26e4-44fb-ae19-906f5fe9435d":
+            if r["direction"] == "backward":
+                metadata["~karaoke"] = "yes"
+        if r["target-type"] == "work":
+            if r["work"]["type-id"] == "40ed00fb-cd1d-3de5-afcc-4d08720d63e7":
+                metadata["~drama"] = "yes"
 
 if modulename() in config.setting["enabled_plugins"]:
     register_track_metadata_processor(add_metadata)