CC-5709: Airtime Analyzer

* A bunch of cleanup and fix for metadata extraction on files mutagen can't read
This commit is contained in:
Albert Santoni 2014-04-04 12:35:50 -04:00
parent 64a95c7c59
commit cf492045cc
2 changed files with 15 additions and 15 deletions

View File

@ -332,16 +332,11 @@ class Rest_MediaController extends Zend_Rest_Controller
{
$CC_CONFIG = Config::getConfig();
$apiKey = $CC_CONFIG["apiKey"][0];
//$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
//$tempFilePath = Application_Model_StoredFile::uploadFile($upload_dir);
$tempFilePath = $_FILES['file']['tmp_name'];
$tempFileName = basename($tempFilePath);
//TODO: Remove copyFileToStor from StoredFile...
//TODO: Remove uploadFileAction from ApiController.php **IMPORTANT** - It's used by the recorder daemon?
//TODO: Remove uploadFileAction from ApiController.php **IMPORTANT** - It's used by the recorder daemon...
$storDir = Application_Model_MusicDir::getStorDir();
$importedStorageDirectory = $storDir->getDirectory() . "/imported/" . $ownerId;

View File

@ -19,9 +19,20 @@ class MetadataAnalyzer(Analyzer):
if not isinstance(metadata, dict):
raise TypeError("metadata must be a dict. Was of type " + type(metadata).__name__)
#Airtime <= 2.5.x nonsense:
metadata["ftype"] = "audioclip"
#Other fields we'll want to set for Airtime:
metadata["cueout"] = metadata["length"]
metadata["hidden"] = False
#Extract metadata from an audio file using mutagen
audio_file = mutagen.File(filename, easy=True)
#Bail if the file couldn't be parsed. The title should stay as the filename
#inside Airtime.
if not audio_file:
return metadata
#Grab other file information that isn't encoded in a tag, but instead usually
#in the file header. Mutagen breaks that out into a separate "info" object:
info = audio_file.info
@ -53,7 +64,7 @@ class MetadataAnalyzer(Analyzer):
except (AttributeError, KeyError):
#If mutagen can't figure out the number of channels, we'll just leave it out...
pass
#Try to extract the number of tracks on the album if we can (the "track total")
try:
track_number = audio_file["tracknumber"]
@ -107,12 +118,6 @@ class MetadataAnalyzer(Analyzer):
except KeyError:
continue
#Airtime <= 2.5.x nonsense:
metadata["ftype"] = "audioclip"
#Other fields we'll want to set for Airtime:
metadata["cueout"] = metadata["length"]
metadata["hidden"] = False
return metadata