X-Git-Url: https://git.draconx.ca/gitweb/picard-plugins.git/blobdiff_plain/031be6cdea38a8982d5df850c0c28d2b834d639a..HEAD:/karaoke-flagger.py diff --git a/karaoke-flagger.py b/karaoke-flagger.py index 13abe78..7263393 100644 --- a/karaoke-flagger.py +++ b/karaoke-flagger.py @@ -1,23 +1,30 @@ # -*- 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. # 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'''

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.

+PLUGIN_DESCRIPTION = u'''

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.

-

The metadata variable %_karaoke% will be set to "yes" on -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.

+
+
%_karaoke%
+
Set to "yes" if the track is a karaoke recording.
+
%_drama%
+
Set to "yes" if the track is a recording of an audio drama.
+
+ +

For example, you could use a tagger script such as +$if(%_karaoke%,$set(comment:karaoke,%_karaoke%)) +to tag karaoke tracks as such in order to help generate playlists +for your next karaoke dance party.

''' -PLUGIN_VERSION = "0" +PLUGIN_VERSION = "2" PLUGIN_API_VERSIONS = ["2.0"] PLUGIN_LICENSE = "GPL-3.0-or-later" @@ -28,13 +35,16 @@ def modulename(): return modulename.__module__[len("picard.plugins."):] def add_metadata(tagger, metadata, track, release): - for r in track["recording"]["relations"]: + # for standalone 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 - 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)