mirror of
https://github.com/fergalmoran/picard.git
synced 2026-04-30 16:21:22 +00:00
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:
34
contrib/plugins/sort_multivalue_tags.py
Normal file
34
contrib/plugins/sort_multivalue_tags.py
Normal 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)
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user