Use Silan to silently update track length in the background

-done
This commit is contained in:
Martin Konecny 2013-04-18 15:40:33 -04:00
parent 9a78c3f8e5
commit 479e69de12
4 changed files with 26 additions and 4 deletions

View File

@ -979,8 +979,24 @@ class ApiController extends Zend_Controller_Action
list($id, $info) = $pair;
// TODO : move this code into model -- RG
$file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm();
//What we are doing here is setting a more accurate length that was
//calculated with silan by actually scanning the entire file. This
//process takes a really long time, and so we only do it in the background
//after the file has already been imported -MK
$length = $file->getDbLength();
if (isset($info['length'])) {
$length = $info['length'];
//length decimal number in seconds. Need to convert it to format
//HH:mm:ss to get around silly PHP limitations.
$length = Application_Common_DateHelper::secondsToPlaylistTime($length);
$file->setDbLength($length);
}
$cuein = isset($info['cuein']) ? $info['cuein'] : 0;
$cueout = isset($info['cueout']) ? $info['cueout'] : $file->getDbLength();
$cueout = isset($info['cueout']) ? $info['cueout'] : $length;
$file->setDbCuein($cuein);
$file->setDbCueout($cueout);
$file->setDbSilanCheck(true);

View File

@ -20,6 +20,8 @@ class CcFiles extends BaseCcFiles {
public function setDbLength($v)
{
//we are using DateTime instead of DateInterval because the latter doesn't
//support subseconds :(
if ($v instanceof DateTime) {
$dt = $v;
}

View File

@ -49,9 +49,12 @@ class SilanAnalyzer(Thread):
if len(comm):
out = comm[0].strip('\r\n')
info = json.loads(out)
if len(info['sound']) >= 2:
data['cuein'] = str('{0:f}'.format(info['sound'][0][0]))
data['cueout'] = str('{0:f}'.format(info['sound'][-1][1]))
try: data['length'] = str('{0:f}'.format(info['file duration']))
except: pass
try: data['cuein'] = str('{0:f}'.format(info['sound'][0][0]))
except: pass
try: data['cueout'] = str('{0:f}'.format(info['sound'][-1][1]))
except: pass
except Exception, e:
self.logger.error(str(command))
self.logger.error(e)

View File

@ -55,6 +55,7 @@ try:
data = {}
data['cuein'] = str('{0:f}'.format(info['sound'][0][0]))
data['cueout'] = str('{0:f}'.format(info['sound'][-1][1]))
data['length'] = str('{0:f}'.format(info['file duration']))
processed_data.append((f['id'], data))
total += 1
if total % 5 == 0: