try:
text.encode(encoding)
except UnicodeEncodeError:
- encoding_success == False
+ encoding_success = False
break
if encoding_success:
return id3_encoding
if mp3.tags is not None:
mp3.tags.delete()
handled_trck = False
+ max_encoding = 0
for key,value in metadata.items():
if key == 'date':
for i,v in enumerate(value):
continue
frame = getattr(mutagen.id3, frame_name)
id3_encoding = self._guess_id3_encoding(value)
+ max_encoding = max(max_encoding, id3_encoding)
mp3[frame_name] = frame(encoding=id3_encoding, text=value)
if mp3.tags is None:
return
- mp3.save(v1=2)
+ if max_encoding: # at least one tag doesn't use ISO-8859-1
+ v1 = 0 # remove ID3v1 tags
+ else:
+ v1 = 2 # create and/or update ID3v1 tags
+ mp3.save(v1=v1)
def set_ogg_metadata(self, target, metadata):
if mutagen is None: