Allow missing fields in %aunique (#1775)

This commit is contained in:
Adrian Sampson 2015-12-28 15:28:27 -08:00
parent b25b4db9e1
commit ed9b5ef9cb
2 changed files with 4 additions and 2 deletions

View file

@ -1421,7 +1421,7 @@ class DefaultTemplateFunctions(object):
# Find matching albums to disambiguate with.
subqueries = []
for key in keys:
value = getattr(album, key)
value = album.get(key, '')
subqueries.append(dbcore.MatchQuery(key, value))
albums = self.lib.albums(dbcore.AndQuery(subqueries))
@ -1434,7 +1434,7 @@ class DefaultTemplateFunctions(object):
# Find the first disambiguator that distinguishes the albums.
for disambiguator in disam:
# Get the value for each album for the current field.
disam_values = set([getattr(a, disambiguator) for a in albums])
disam_values = set([a.get(disambiguator, '') for a in albums])
# If the set of unique values is equal to the number of
# albums in the disambiguation set, we're done -- this is

View file

@ -92,6 +92,8 @@ Fixes:
did. :bug:`1657`
* :doc:`/plugins/scrub`: Also in ``auto`` mode, album art is now correctly
restored. :bug:`1657`
* Possibly allow flexible attributes to be used with the ``%aunique`` template
function. :bug:`1775`
.. _Emby Server: http://emby.media