fix smart_update to replace tags and comments even when empty when replace_metadata is true.

This commit is contained in:
Charles Haley 2010-07-19 09:55:56 +01:00
parent 77ddc1fedf
commit dd1ef60d1d

View File

@ -295,11 +295,10 @@ class MetaInformation(object):
if val is not None: if val is not None:
setattr(self, attr, val) setattr(self, attr, val)
if mi.tags: if replace_metadata:
if replace_metadata: self.tags = mi.tags
self.tags = mi.tags elif mi.tags:
else: self.tags += mi.tags
self.tags += mi.tags
self.tags = list(set(self.tags)) self.tags = list(set(self.tags))
if mi.author_sort_map: if mi.author_sort_map:
@ -313,14 +312,17 @@ class MetaInformation(object):
if len(other_cover) > len(self_cover): if len(other_cover) > len(self_cover):
self.cover_data = mi.cover_data self.cover_data = mi.cover_data
my_comments = getattr(self, 'comments', '') if replace_metadata:
other_comments = getattr(mi, 'comments', '') self.comments = getattr(mi, 'comments', '')
if not my_comments: else:
my_comments = '' my_comments = getattr(self, 'comments', '')
if not other_comments: other_comments = getattr(mi, 'comments', '')
other_comments = '' if not my_comments:
if len(other_comments.strip()) > len(my_comments.strip()): my_comments = ''
self.comments = other_comments if not other_comments:
other_comments = ''
if len(other_comments.strip()) > len(my_comments.strip()):
self.comments = other_comments
other_lang = getattr(mi, 'language', None) other_lang = getattr(mi, 'language', None)
if other_lang and other_lang.lower() != 'und': if other_lang and other_lang.lower() != 'und':