cc-4397: Fixed handling for bad metadata.

This commit is contained in:
Rudi Grinberg 2012-09-12 17:26:37 -04:00
parent e708f60f68
commit 8e91c515f0
3 changed files with 12 additions and 2 deletions

View File

@ -207,7 +207,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
return false; return false;
} }
} }
return true; return true;
} }

View File

@ -2,6 +2,7 @@
from kombu.messaging import Exchange, Queue, Consumer from kombu.messaging import Exchange, Queue, Consumer
from kombu.connection import BrokerConnection from kombu.connection import BrokerConnection
from os.path import normpath from os.path import normpath
from mutagen.easymp4 import EasyMP4KeyError
import json import json
import os import os
@ -117,6 +118,10 @@ class AirtimeMessageReceiver(Loggable):
try: Metadata.write_unsafe(path=md_path, md=msg) try: Metadata.write_unsafe(path=md_path, md=msg)
except BadSongFile as e: except BadSongFile as e:
self.logger.info("Cannot find metadata file: '%s'" % e.path) 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: except Exception as e:
# TODO : add md_path to problem path or something? # TODO : add md_path to problem path or something?
self.fatal_exception("Unknown error when writing metadata to: '%s'" self.fatal_exception("Unknown error when writing metadata to: '%s'"

View File

@ -3,6 +3,7 @@ import mutagen
import math import math
import os import os
import copy import copy
from mutagen.easymp4 import EasyMP4KeyError
from media.monitor.exceptions import BadSongFile from media.monitor.exceptions import BadSongFile
from media.monitor.log import Loggable from media.monitor.log import Loggable
@ -150,12 +151,17 @@ class Metadata(Loggable):
""" """
if not os.path.exists(path): raise BadSongFile(path) if not os.path.exists(path): raise BadSongFile(path)
song_file = mutagen.File(path, easy=True) song_file = mutagen.File(path, easy=True)
ex = None
for airtime_k, airtime_v in md.iteritems(): for airtime_k, airtime_v in md.iteritems():
if airtime_k in airtime2mutagen: if airtime_k in airtime2mutagen:
# The unicode cast here is mostly for integers that need to be # The unicode cast here is mostly for integers that need to be
# strings # strings
try:
song_file[ airtime2mutagen[airtime_k] ] = unicode(airtime_v) song_file[ airtime2mutagen[airtime_k] ] = unicode(airtime_v)
except EasyMP4KeyError as e:
ex = e
song_file.save() song_file.save()
if ex: raise ex
def __init__(self, fpath): def __init__(self, fpath):
# Forcing the unicode through # Forcing the unicode through