cc-4421: Added special handling for files that mutagen returns None for.

This commit is contained in:
Rudi Grinberg 2012-09-13 14:54:52 -04:00
parent 4137602116
commit 8d08aa888b
2 changed files with 10 additions and 5 deletions

View File

@ -901,7 +901,7 @@ class ApiController extends Zend_Controller_Action
foreach ($data as $pair) {
list($id, $gain) = $pair;
// TODO : move this code into model -- RG
$file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm();
$file->setDbReplayGain($gain);
$file->save();

View File

@ -178,14 +178,19 @@ class Metadata(Loggable):
return
# TODO : Simplify the way all of these rules are handled right not it's
# extremely unclear and needs to be refactored.
if full_mutagen is None: raise BadSongFile(fpath)
#if full_mutagen is None: raise BadSongFile(fpath)
if full_mutagen is None: full_mutagen = {}
self.__metadata = Metadata.airtime_dict(full_mutagen)
# Now we extra the special values that are calculated from the mutagen
# object itself:
for special_key,f in airtime_special.iteritems():
try:
new_val = f(full_mutagen)
if new_val is not None:
self.__metadata[special_key] = new_val
except Exception:
self.logger.info("Could not get special key %s for %d" %
special_key, fpath)
# Finally, we "normalize" all the metadata here:
self.__metadata = mmp.normalized_metadata(self.__metadata, fpath)
# Now we must load the md5: