Remove sorting for displayed multi-value tags and provide a sort tags plugin

Picard stores tags unsorted but displays them sorted and this is
inconsistent.

This commit removes display sorting of multi-value tags from Picard
improves consistency by displaying what will be / is actually saved.

This commit also provides a plug-in to allow user to sort tags both
displayed and stored in the file.
This commit is contained in:
Sophist
2013-06-03 08:17:53 +01:00
parent 1605adbd7b
commit 738fbd94d5
2 changed files with 34 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# This is the Sort Multivalue Tags plugin for MusicBrainz Picard.
# Copyright (C) 2013 Sophist
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
PLUGIN_NAME = u"Sort Multi-Value Tags"
PLUGIN_AUTHOR = u"Sophist"
PLUGIN_DESCRIPTION = u'Sort Multi-Value Tags e.g. Release Type, Lyrics alphabetically.'
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["0.15"]
from picard.metadata import register_track_metadata_processor
# Define and register the Track Metadata function
def sort_multivalue_tags(tagger, metadata, track, release):
for tag in filter(lambda x: len(metadata[x]) > 1, metadata.keys()):
data = metadata.getall(tag)
if len(data) > 1:
sorted_data = sorted(data)
if data != sorted_data:
metadata.set(tag,sorted_data)
register_track_metadata_processor(sort_multivalue_tags)

View File

@@ -99,11 +99,9 @@ class TagDiff:
def add(self, tag, orig_values, new_values, removable):
if orig_values:
orig_values = sorted(orig_values)
self.orig.add(tag, orig_values)
if new_values:
new_values = sorted(new_values)
self.new.add(tag, new_values)
if orig_values and not new_values: