cc-4397: Fixed handling for bad metadata.
This commit is contained in:
parent
e708f60f68
commit
8e91c515f0
|
@ -207,7 +207,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from kombu.messaging import Exchange, Queue, Consumer
|
||||
from kombu.connection import BrokerConnection
|
||||
from os.path import normpath
|
||||
from mutagen.easymp4 import EasyMP4KeyError
|
||||
|
||||
import json
|
||||
import os
|
||||
|
@ -117,6 +118,10 @@ class AirtimeMessageReceiver(Loggable):
|
|||
try: Metadata.write_unsafe(path=md_path, md=msg)
|
||||
except BadSongFile as e:
|
||||
self.logger.info("Cannot find metadata file: '%s'" % e.path)
|
||||
except EasyMP4KeyError as e:
|
||||
self.logger.info("Metadata instance not supported for this file '%s'" \
|
||||
% e.path)
|
||||
self.logger.info(str(e))
|
||||
except Exception as e:
|
||||
# TODO : add md_path to problem path or something?
|
||||
self.fatal_exception("Unknown error when writing metadata to: '%s'"
|
||||
|
|
|
@ -3,6 +3,7 @@ import mutagen
|
|||
import math
|
||||
import os
|
||||
import copy
|
||||
from mutagen.easymp4 import EasyMP4KeyError
|
||||
|
||||
from media.monitor.exceptions import BadSongFile
|
||||
from media.monitor.log import Loggable
|
||||
|
@ -150,12 +151,17 @@ class Metadata(Loggable):
|
|||
"""
|
||||
if not os.path.exists(path): raise BadSongFile(path)
|
||||
song_file = mutagen.File(path, easy=True)
|
||||
ex = None
|
||||
for airtime_k, airtime_v in md.iteritems():
|
||||
if airtime_k in airtime2mutagen:
|
||||
# The unicode cast here is mostly for integers that need to be
|
||||
# strings
|
||||
song_file[ airtime2mutagen[airtime_k] ] = unicode(airtime_v)
|
||||
try:
|
||||
song_file[ airtime2mutagen[airtime_k] ] = unicode(airtime_v)
|
||||
except EasyMP4KeyError as e:
|
||||
ex = e
|
||||
song_file.save()
|
||||
if ex: raise ex
|
||||
|
||||
def __init__(self, fpath):
|
||||
# Forcing the unicode through
|
||||
|
|
Loading…
Reference in New Issue