CC-2612 : Upgrade: Push DB metadata into the file before upgrade

testing saving non ascii characters to file.
This commit is contained in:
Naomi Aro 2011-08-01 18:10:50 +02:00
parent 6848963904
commit 7e64e1ba22
2 changed files with 14 additions and 7 deletions

View file

@ -91,7 +91,12 @@ class AirtimeMetadata:
for key in m.keys() : for key in m.keys() :
if key in self.airtime2mutagen: if key in self.airtime2mutagen:
value = m[key] value = m[key]
if ((value is not None) and (len(str(value)) > 0)): if (value is not None):
self.logger.debug("Saving %s to file", key)
self.logger.debug(value)
if isinstance(value, basestring) and (len(value) > 0):
airtime_file[self.airtime2mutagen[key]] = unicode(value, "utf-8")
elif isinstance(value, int):
airtime_file[self.airtime2mutagen[key]] = str(value) airtime_file[self.airtime2mutagen[key]] = str(value)
@ -144,9 +149,6 @@ class AirtimeMetadata:
if isinstance(md['MDATA_KEY_TRACKNUMBER'], basestring): if isinstance(md['MDATA_KEY_TRACKNUMBER'], basestring):
match = re.search('^(\d*/\d*)?', md['MDATA_KEY_TRACKNUMBER']) match = re.search('^(\d*/\d*)?', md['MDATA_KEY_TRACKNUMBER'])
self.logger.debug("parsing track number")
self.logger.debug(md['MDATA_KEY_TRACKNUMBER'])
self.logger.debug(match.group(0))
if match.group(0) is not u'': if match.group(0) is not u'':
md['MDATA_KEY_TRACKNUMBER'] = int(md['MDATA_KEY_TRACKNUMBER'].split("/")[0]) md['MDATA_KEY_TRACKNUMBER'] = int(md['MDATA_KEY_TRACKNUMBER'].split("/")[0])

View file

@ -91,7 +91,12 @@ class AirtimeMetadata:
for key in m.keys() : for key in m.keys() :
if key in self.airtime2mutagen: if key in self.airtime2mutagen:
value = m[key] value = m[key]
if ((value is not None) and (len(str(value)) > 0)): if (value is not None):
self.logger.debug("Saving %s to file", key)
self.logger.debug(value)
if isinstance(value, basestring) and (len(value) > 0):
airtime_file[self.airtime2mutagen[key]] = unicode(value, "utf-8")
elif isinstance(value, int):
airtime_file[self.airtime2mutagen[key]] = str(value) airtime_file[self.airtime2mutagen[key]] = str(value)