mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 12:32:33 +01:00
Use item[field] instead of getattr(item, field)
This commit is contained in:
parent
19d3ca822e
commit
492cf38927
2 changed files with 7 additions and 8 deletions
|
|
@ -65,10 +65,10 @@ def current_metadata(items):
|
|||
fields = ['artist', 'album', 'albumartist', 'year', 'disctotal',
|
||||
'mb_albumid', 'label', 'catalognum', 'country', 'media',
|
||||
'albumdisambig']
|
||||
for key in fields:
|
||||
values = [getattr(item, key) for item in items if item]
|
||||
likelies[key], freq = plurality(values)
|
||||
consensus[key] = (freq == len(values))
|
||||
for field in fields:
|
||||
values = [item[field] for item in items if item]
|
||||
likelies[field], freq = plurality(values)
|
||||
consensus[field] = (freq == len(values))
|
||||
|
||||
# If there's an album artist consensus, use this for the artist.
|
||||
if consensus['albumartist'] and likelies['albumartist']:
|
||||
|
|
|
|||
|
|
@ -85,12 +85,11 @@ class ZeroPlugin(BeetsPlugin):
|
|||
return
|
||||
|
||||
for field, patterns in self.patterns.items():
|
||||
try:
|
||||
value = getattr(item, field)
|
||||
except AttributeError:
|
||||
if field not in item.keys():
|
||||
log.error(u'[zero] no such field: {0}'.format(field))
|
||||
continue
|
||||
|
||||
value = item[field]
|
||||
if self.match_patterns(value, patterns):
|
||||
log.debug(u'[zero] {0}: {1} -> None'.format(field, value))
|
||||
setattr(item, field, None)
|
||||
item[field] = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue