Merge branch 'cc-5709-airtime-analyzer' into cc-5709-airtime-analyzer-saas
This commit is contained in:
commit
65ea0e6d6f
|
@ -376,31 +376,35 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
|
|
||||||
private function validateRequestData($file, &$whiteList)
|
private function validateRequestData($file, &$whiteList)
|
||||||
{
|
{
|
||||||
// EditAudioMD form is used here for validation
|
try {
|
||||||
$fileForm = new Application_Form_EditAudioMD();
|
// EditAudioMD form is used here for validation
|
||||||
$fileForm->startForm($file->getDbId());
|
$fileForm = new Application_Form_EditAudioMD();
|
||||||
$fileForm->populate($whiteList);
|
$fileForm->startForm($file->getDbId());
|
||||||
|
$fileForm->populate($whiteList);
|
||||||
/*
|
|
||||||
* Here we are truncating metadata of any characters greater than the
|
/*
|
||||||
* max string length set in the database. In the rare case a track's
|
* Here we are truncating metadata of any characters greater than the
|
||||||
* genre is more than 64 chars, for example, we don't want to reject
|
* max string length set in the database. In the rare case a track's
|
||||||
* tracks for that reason
|
* genre is more than 64 chars, for example, we don't want to reject
|
||||||
*/
|
* tracks for that reason
|
||||||
foreach($whiteList as $tag => &$value) {
|
*/
|
||||||
if ($fileForm->getElement($tag)) {
|
foreach($whiteList as $tag => &$value) {
|
||||||
$stringLengthValidator = $fileForm->getElement($tag)->getValidator('StringLength');
|
if ($fileForm->getElement($tag)) {
|
||||||
//$stringLengthValidator will be false if the StringLength validator doesn't exist on the current element
|
$stringLengthValidator = $fileForm->getElement($tag)->getValidator('StringLength');
|
||||||
//in which case we don't have to truncate the extra characters
|
//$stringLengthValidator will be false if the StringLength validator doesn't exist on the current element
|
||||||
if ($stringLengthValidator) {
|
//in which case we don't have to truncate the extra characters
|
||||||
$value = substr($value, 0, $stringLengthValidator->getMax());
|
if ($stringLengthValidator) {
|
||||||
|
$value = substr($value, 0, $stringLengthValidator->getMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = $this->stripInvalidUtf8Characters($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = $this->stripInvalidUtf8Characters($value);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (!$fileForm->isValidPartial($whiteList)) {
|
||||||
if (!$fileForm->isValidPartial($whiteList)) {
|
throw Exception("Data validation failed");
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
$errors = $fileForm->getErrors();
|
$errors = $fileForm->getErrors();
|
||||||
$messages = $fileForm->getMessages();
|
$messages = $fileForm->getMessages();
|
||||||
Logging::error($messages);
|
Logging::error($messages);
|
||||||
|
|
|
@ -132,7 +132,10 @@ class MetadataAnalyzer(Analyzer):
|
||||||
# Some tags are returned as lists because there could be multiple values.
|
# Some tags are returned as lists because there could be multiple values.
|
||||||
# This is unusual so we're going to always just take the first item in the list.
|
# This is unusual so we're going to always just take the first item in the list.
|
||||||
if isinstance(metadata[airtime_tag], list):
|
if isinstance(metadata[airtime_tag], list):
|
||||||
metadata[airtime_tag] = metadata[airtime_tag][0]
|
if metadata[airtime_tag]:
|
||||||
|
metadata[airtime_tag] = metadata[airtime_tag][0]
|
||||||
|
else: # Handle empty lists
|
||||||
|
metadata[airtime_tag] = ""
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue