Skip to content

Commit 2382d11

Browse files
committed
Merge pull request #2758 from cgevans/master
Duplicates plugin: tiebreak album vs items fix
2 parents d932aa4 + dd2b44e commit 2382d11

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

beetsplug/duplicates.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,19 @@ def _order(self, objs, tiebreak=None):
253253
"completeness" (objects with more non-null fields come first)
254254
and Albums are ordered by their track count.
255255
"""
256-
if tiebreak:
257-
kind = 'items' if all(isinstance(o, Item)
258-
for o in objs) else 'albums'
256+
kind = 'items' if all(isinstance(o, Item) for o in objs) else 'albums'
257+
258+
if tiebreak and kind in tiebreak.keys():
259259
key = lambda x: tuple(getattr(x, k) for k in tiebreak[kind])
260260
else:
261-
kind = Item if all(isinstance(o, Item) for o in objs) else Album
262-
if kind is Item:
261+
if kind == 'items':
263262
def truthy(v):
264263
# Avoid a Unicode warning by avoiding comparison
265264
# between a bytes object and the empty Unicode
266265
# string ''.
267266
return v is not None and \
268267
(v != '' if isinstance(v, six.text_type) else True)
269-
fields = kind.all_keys()
268+
fields = Item.all_keys()
270269
key = lambda x: sum(1 for f in fields if truthy(getattr(x, f)))
271270
else:
272271
key = lambda x: len(x.items())

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Fixes:
7070
Python 3 on Windows with non-ASCII filenames. :bug:`2671`
7171
* :doc:`/plugins/absubmit`: Fix an occasional crash on Python 3 when the AB
7272
analysis tool produced non-ASCII metadata. :bug:`2673`
73+
* :doc:`/plugins/duplicates`: Use default tiebreak for any kind (item/album) that
74+
does not have a tiebreak specified in the configuration.
7375
* :doc:`/plugins/duplicates`: Fix the `--key` command line option, which was
7476
ignored.
7577
* :doc:`/plugins/replaygain`: Fix album replaygain calculation with the

0 commit comments

Comments
 (0)