mirror of
https://github.com/beetbox/beets.git
synced 2025-12-26 02:24:33 +01:00
Merge pull request #2758 from cgevans/master
Duplicates plugin: tiebreak album vs items fix
This commit is contained in:
commit
2382d1182c
2 changed files with 7 additions and 6 deletions
|
|
@ -253,20 +253,19 @@ class DuplicatesPlugin(BeetsPlugin):
|
|||
"completeness" (objects with more non-null fields come first)
|
||||
and Albums are ordered by their track count.
|
||||
"""
|
||||
if tiebreak:
|
||||
kind = 'items' if all(isinstance(o, Item)
|
||||
for o in objs) else 'albums'
|
||||
kind = 'items' if all(isinstance(o, Item) for o in objs) else 'albums'
|
||||
|
||||
if tiebreak and kind in tiebreak.keys():
|
||||
key = lambda x: tuple(getattr(x, k) for k in tiebreak[kind])
|
||||
else:
|
||||
kind = Item if all(isinstance(o, Item) for o in objs) else Album
|
||||
if kind is Item:
|
||||
if kind == 'items':
|
||||
def truthy(v):
|
||||
# Avoid a Unicode warning by avoiding comparison
|
||||
# between a bytes object and the empty Unicode
|
||||
# string ''.
|
||||
return v is not None and \
|
||||
(v != '' if isinstance(v, six.text_type) else True)
|
||||
fields = kind.all_keys()
|
||||
fields = Item.all_keys()
|
||||
key = lambda x: sum(1 for f in fields if truthy(getattr(x, f)))
|
||||
else:
|
||||
key = lambda x: len(x.items())
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ Fixes:
|
|||
Python 3 on Windows with non-ASCII filenames. :bug:`2671`
|
||||
* :doc:`/plugins/absubmit`: Fix an occasional crash on Python 3 when the AB
|
||||
analysis tool produced non-ASCII metadata. :bug:`2673`
|
||||
* :doc:`/plugins/duplicates`: Use default tiebreak for any kind (item/album) that
|
||||
does not have a tiebreak specified in the configuration.
|
||||
* :doc:`/plugins/duplicates`: Fix the `--key` command line option, which was
|
||||
ignored.
|
||||
* :doc:`/plugins/replaygain`: Fix album replaygain calculation with the
|
||||
|
|
|
|||
Loading…
Reference in a new issue