Merge branch 'cc-5709-airtime-analyzer' into saas

This commit is contained in:
Albert Santoni 2014-07-15 16:46:20 -04:00
commit 490a9c0d06
14 changed files with 65 additions and 44 deletions

View File

@ -738,13 +738,16 @@ SQL;
$replay_gain = is_null($item["replay_gain"]) ? "0": $item["replay_gain"]; $replay_gain = is_null($item["replay_gain"]) ? "0": $item["replay_gain"];
$replay_gain += Application_Model_Preference::getReplayGainModifier(); $replay_gain += Application_Model_Preference::getReplayGainModifier();
if ( !Application_Model_Preference::GetEnableReplayGain() ) { if (!Application_Model_Preference::GetEnableReplayGain() ) {
$replay_gain = 0; $replay_gain = 0;
} }
$fileMetadata = CcFiles::sanitizeResponse(CcFilesQuery::create()->findPk($media_id));
$schedule_item = array( $schedule_item = array(
'id' => $media_id, 'id' => $media_id,
'type' => 'file', 'type' => 'file',
'metadata' => $fileMetadata,
'row_id' => $item["id"], 'row_id' => $item["id"],
'uri' => $uri, 'uri' => $uri,
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]), 'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),

View File

@ -13,6 +13,14 @@
*/ */
class CcFiles extends BaseCcFiles { class CcFiles extends BaseCcFiles {
//fields we should never expose through our RESTful API
private static $privateFields = array(
'file_exists',
'silan_check',
'is_scheduled',
'is_playlist'
);
public function getCueLength() public function getCueLength()
{ {
$cuein = $this->getDbCuein(); $cuein = $this->getDbCuein();
@ -46,4 +54,20 @@ class CcFiles extends BaseCcFiles {
$this->save(); $this->save();
} }
/**
*
* Strips out the private fields we do not want to send back in API responses
* @param $file a CcFiles object
*/
//TODO: rename this function?
public static function sanitizeResponse($file)
{
$response = $file->toArray(BasePeer::TYPE_FIELDNAME);
foreach (self::$privateFields as $key) {
unset($response[$key]);
}
return $response;
}
} // CcFiles } // CcFiles

View File

@ -4,7 +4,7 @@
class Rest_MediaController extends Zend_Rest_Controller class Rest_MediaController extends Zend_Rest_Controller
{ {
//fields that are not modifiable via our RESTful API //fields that are not modifiable via our RESTful API
private $blackList = array( private static $blackList = array(
'id', 'id',
'directory', 'directory',
'filepath', 'filepath',
@ -18,14 +18,6 @@ class Rest_MediaController extends Zend_Rest_Controller
'is_playlist' 'is_playlist'
); );
//fields we should never expose through our RESTful API
private $privateFields = array(
'file_exists',
'silan_check',
'is_scheduled',
'is_playlist'
);
public function init() public function init()
{ {
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
@ -41,7 +33,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$files_array = array(); $files_array = array();
foreach (CcFilesQuery::create()->find() as $file) foreach (CcFilesQuery::create()->find() as $file)
{ {
array_push($files_array, $this->sanitizeResponse($file)); array_push($files_array, CcFiles::sanitizeResponse($file));
} }
$this->getResponse() $this->getResponse()
@ -127,7 +119,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$this->getResponse() $this->getResponse()
->setHttpResponseCode(200) ->setHttpResponseCode(200)
->appendBody(json_encode($this->sanitizeResponse($file))); ->appendBody(json_encode(CcFiles::sanitizeResponse($file)));
} else { } else {
$this->fileNotFoundResponse(); $this->fileNotFoundResponse();
} }
@ -194,7 +186,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$this->getResponse() $this->getResponse()
->setHttpResponseCode(201) ->setHttpResponseCode(201)
->appendBody(json_encode($this->sanitizeResponse($file))); ->appendBody(json_encode(CcFiles::sanitizeResponse($file)));
} }
} }
@ -258,7 +250,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$this->getResponse() $this->getResponse()
->setHttpResponseCode(200) ->setHttpResponseCode(200)
->appendBody(json_encode($this->sanitizeResponse($file))); ->appendBody(json_encode(CcFiles::sanitizeResponse($file)));
} else { } else {
$file->setDbImportStatus(2)->save(); $file->setDbImportStatus(2)->save();
$this->fileNotFoundResponse(); $this->fileNotFoundResponse();
@ -483,30 +475,15 @@ class Rest_MediaController extends Zend_Rest_Controller
* from outside of Airtime * from outside of Airtime
* @param array $data * @param array $data
*/ */
private function removeBlacklistedFieldsFromRequestData($data) private static function removeBlacklistedFieldsFromRequestData($data)
{ {
foreach ($this->blackList as $key) { foreach (self::$blackList as $key) {
unset($data[$key]); unset($data[$key]);
} }
return $data; return $data;
} }
/**
*
* Strips out the private fields we do not want to send back in API responses
*/
//TODO: rename this function?
public function sanitizeResponse($file)
{
$response = $file->toArray(BasePeer::TYPE_FIELDNAME);
foreach ($this->privateFields as $key) {
unset($response[$key]);
}
return $response;
}
private function removeEmptySubFolders($path) private function removeEmptySubFolders($path)
{ {

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Airtime\n" "Project-Id-Version: Airtime\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-13 12:58-0500\n" "POT-Creation-Date: 2013-12-13 12:58-0500\n"
"PO-Revision-Date: 2014-06-14 14:00+0000\n" "PO-Revision-Date: 2014-07-02 12:01+0000\n"
"Last-Translator: Daniel James <daniel@64studio.com>\n" "Last-Translator: Daniel James <daniel@64studio.com>\n"
"Language-Team: Azerbaijani (http://www.transifex.com/projects/p/airtime/language/az/)\n" "Language-Team: Azerbaijani (http://www.transifex.com/projects/p/airtime/language/az/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Airtime\n" "Project-Id-Version: Airtime\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-13 12:58-0500\n" "POT-Creation-Date: 2013-12-13 12:58-0500\n"
"PO-Revision-Date: 2014-06-10 22:00+0000\n" "PO-Revision-Date: 2014-06-25 15:01+0000\n"
"Last-Translator: Daniel James <daniel@64studio.com>\n" "Last-Translator: Daniel James <daniel@64studio.com>\n"
"Language-Team: Armenian (http://www.transifex.com/projects/p/airtime/language/hy/)\n" "Language-Team: Armenian (http://www.transifex.com/projects/p/airtime/language/hy/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Airtime\n" "Project-Id-Version: Airtime\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-13 12:58-0500\n" "POT-Creation-Date: 2013-12-13 12:58-0500\n"
"PO-Revision-Date: 2014-06-05 11:14+0000\n" "PO-Revision-Date: 2014-07-02 12:01+0000\n"
"Last-Translator: Daniel James <daniel@64studio.com>\n" "Last-Translator: Daniel James <daniel@64studio.com>\n"
"Language-Team: Georgian (http://www.transifex.com/projects/p/airtime/language/ka/)\n" "Language-Team: Georgian (http://www.transifex.com/projects/p/airtime/language/ka/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"

View File

@ -44,5 +44,8 @@ while not successful:
logging.error("traceback: %s", traceback.format_exc()) logging.error("traceback: %s", traceback.format_exc())
sys.exit(1) sys.exit(1)
else: else:
logging.error(str(e))
logging.error("traceback: %s", traceback.format_exc())
logging.info("Retrying in 3 seconds...")
time.sleep(3) time.sleep(3)
attempts += 1 attempts += 1

View File

@ -3,17 +3,31 @@ from timeout import ls_timeout
def create_liquidsoap_annotation(media): def create_liquidsoap_annotation(media):
# We need liq_start_next value in the annotate. That is the value that controls overlap duration of crossfade. # We need liq_start_next value in the annotate. That is the value that controls overlap duration of crossfade.
return ('annotate:media_id="%s",liq_start_next="0",liq_fade_in="%s",' + \
filename = media['dst']
annotation = ('annotate:media_id="%s",liq_start_next="0",liq_fade_in="%s",' + \
'liq_fade_out="%s",liq_cue_in="%s",liq_cue_out="%s",' + \ 'liq_fade_out="%s",liq_cue_in="%s",liq_cue_out="%s",' + \
'schedule_table_id="%s",replay_gain="%s dB":%s') % \ 'schedule_table_id="%s",replay_gain="%s dB"') % \
(media['id'], (media['id'],
float(media['fade_in']) / 1000, float(media['fade_in']) / 1000,
float(media['fade_out']) / 1000, float(media['fade_out']) / 1000,
float(media['cue_in']), float(media['cue_in']),
float(media['cue_out']), float(media['cue_out']),
media['row_id'], media['row_id'],
media['replay_gain'], media['replay_gain'])
media['dst'])
# Override the the artist/title that Liquidsoap extracts from a file's metadata
# with the metadata we get from Airtime. (You can modify metadata in Airtime's library,
# which doesn't get saved back to the file.)
if 'metadata' in media:
if 'artist_name' in media['metadata']:
annotation += ',artist="%s"' % (media['metadata']['artist_name'])
if 'track_title' in media['metadata']:
annotation += ',title="%s"' % (media['metadata']['track_title'])
annotation += ":" + filename
return annotation
class TelnetLiquidsoap: class TelnetLiquidsoap: