CC-3750Media Library->Edit Metadata: media-monitor throw exception when trying to edit metadata with non-ascii characters
-Improved save metadata function
This commit is contained in:
parent
906b6e8bd0
commit
676205bb00
3 changed files with 10 additions and 11 deletions
|
@ -88,17 +88,16 @@ class AirtimeMetadata:
|
||||||
try:
|
try:
|
||||||
airtime_file = mutagen.File(m['MDATA_KEY_FILEPATH'], easy=True)
|
airtime_file = mutagen.File(m['MDATA_KEY_FILEPATH'], easy=True)
|
||||||
|
|
||||||
for key in m.keys() :
|
for key in m:
|
||||||
if key in self.airtime2mutagen:
|
if key in self.airtime2mutagen:
|
||||||
value = m[key]
|
value = m[key]
|
||||||
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]] = api_client.encode_to(value, 'utf-8')
|
|
||||||
elif isinstance(value, int):
|
|
||||||
airtime_file[self.airtime2mutagen[key]] = str(value)
|
|
||||||
|
|
||||||
|
if value is not None:
|
||||||
|
value = unicode(value)
|
||||||
|
|
||||||
|
if len(value) > 0:
|
||||||
|
self.logger.debug("Saving key '%s' with value '%s' to file", key, value)
|
||||||
|
airtime_file[self.airtime2mutagen[key]] = value
|
||||||
|
|
||||||
airtime_file.save()
|
airtime_file.save()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
|
@ -173,7 +173,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
# update timestamp on create_dict for the entry with pathname as the key
|
# update timestamp on create_dict for the entry with pathname as the key
|
||||||
if pathname in self.create_dict:
|
if pathname in self.create_dict:
|
||||||
self.create_dict[pathname] = time.time()
|
self.create_dict[pathname] = time.time()
|
||||||
if not dir and not self.mmc.is_parent_directory(pathname, self.config.organize_directory) and self.mmc.is_readable(pathname, False):
|
if not dir and not self.mmc.is_parent_directory(pathname, self.config.organize_directory):
|
||||||
self.logger.info("Modified: %s", pathname)
|
self.logger.info("Modified: %s", pathname)
|
||||||
if self.mmc.is_audio_file(name):
|
if self.mmc.is_audio_file(name):
|
||||||
self.file_events.append({'filepath': pathname, 'mode': self.config.MODE_MODIFY})
|
self.file_events.append({'filepath': pathname, 'mode': self.config.MODE_MODIFY})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue