id3: only write WCOP frame for URLs, otherwise use TXXX:LICENSE

This commit is contained in:
Johannes Weißl
2011-12-21 22:58:41 +01:00
parent 180ed5ce2b
commit aa5c1db1c9

View File

@@ -25,6 +25,7 @@ from picard.metadata import Metadata
from picard.file import File
from picard.formats.mutagenext import compatid3
from picard.util import encode_filename, sanitize_date
from urlparse import urlparse
# Ugly, but... I need to save the text in ISO-8859-1 even if it contains
@@ -286,11 +287,11 @@ class ID3File(File):
elif name in self.__rtranslate:
frameid = self.__rtranslate[name]
if frameid.startswith('W'):
# Only add WCOP if there is only one license, otherwise use TXXX:LICENSE
if frameid == 'WCOP' and len(values) > 1:
tags.add(id3.TXXX(encoding=encoding, desc=self.__rtranslate_freetext[name], text=values))
else:
# Only add WCOP if there is only one license URL, otherwise use TXXX:LICENSE
if frameid == 'WCOP' and len(values) == 1 and all(urlparse(values[0])[:2]):
tags.add(getattr(id3, frameid)(url=values[0]))
else:
tags.add(id3.TXXX(encoding=encoding, desc=self.__rtranslate_freetext[name], text=values))
elif frameid.startswith('T'):
tags.add(getattr(id3, frameid)(encoding=encoding, text=values))
elif name in self.__rtranslate_freetext: