def current_metadata(items):
 assert items
 likelies = {}
 consensus = {}
 fields = ['artist', 'album', 'albumartist', 'year', 'disctotal', 'mb_albumid', 'label', 'catalognum', 'country', 'media', 'albumdisambig']
 for field in fields:
  values = [item[field] for item in items if item]
  (likelies[field], freq) = plurality(values)
  consensus[field] = (freq == len(values))
 if (consensus['albumartist'] and likelies['albumartist']):
  likelies['artist'] = likelies['albumartist']
 return (likelies, consensus)

def current_metadata ( items ) : assert items likelies = { } consensus = { } fields = [ 'artist' , 'album' , 'albumartist' , 'year' , 'disctotal' , 'mb_albumid' , 'label' , 'catalognum' , 'country' , 'media' , 'albumdisambig' ] for field in fields : values = [ item [ field ] for item in items if item ] ( likelies [ field ] , freq ) = plurality ( values ) consensus [ field ] = ( freq == len ( values ) ) if ( consensus [ 'albumartist' ] and likelies [ 'albumartist' ] ) : likelies [ 'artist' ] = likelies [ 'albumartist' ] return ( likelies , consensus )
extract the likely current metadata for an album given a list of its items .