From b17f0c01dac7e8a2c18f2fcae0b05ce8021befcc Mon Sep 17 00:00:00 2001 From: Nikolai Prokoschenko Date: Sun, 4 Jan 2009 17:49:02 +0100 Subject: [PATCH] add matchedtracks plugin --- contrib/plugins/matchedtracks.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 contrib/plugins/matchedtracks.py diff --git a/contrib/plugins/matchedtracks.py b/contrib/plugins/matchedtracks.py new file mode 100644 index 000000000..1b9c80413 --- /dev/null +++ b/contrib/plugins/matchedtracks.py @@ -0,0 +1,17 @@ +PLUGIN_NAME = 'Number of matched tracks' +PLUGIN_AUTHOR = 'Nikolai Prokoschenko' +PLUGIN_DESCRIPTION = '''Provides a scripting function called $matchedtracks, which returns the number of tracks matched in an album. Useful for distinguishing complete and incomplete releases''' +PLUGIN_VERSION = "0.1" +PLUGIN_API_VERSIONS = ["0.9.0", "0.10"] + + +from picard.script import register_script_function + +def matchedtracks(parser, arg): + # FIXME arg is actually not needed, why is it used by eval? + if parser.file: + if parser.file.parent: + return str(parser.file.parent.album.get_num_matched_tracks()) + return "0" + +register_script_function(matchedtracks)