Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
8344f3f3d5
|
@ -488,7 +488,7 @@ SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($p_items as $ac) {
|
foreach ($p_items as $ac) {
|
||||||
Logging::info("Adding audio file {$ac[0]}");
|
//Logging::info("Adding audio file {$ac[0]}");
|
||||||
try {
|
try {
|
||||||
if (is_array($ac) && $ac[1] == 'audioclip') {
|
if (is_array($ac) && $ac[1] == 'audioclip') {
|
||||||
$res = $this->insertBlockElement($this->buildEntry($ac[0], $pos));
|
$res = $this->insertBlockElement($this->buildEntry($ac[0], $pos));
|
||||||
|
@ -658,7 +658,7 @@ SQL;
|
||||||
|
|
||||||
public function getFadeInfo($pos)
|
public function getFadeInfo($pos)
|
||||||
{
|
{
|
||||||
Logging::info("Getting fade info for pos {$pos}");
|
//Logging::info("Getting fade info for pos {$pos}");
|
||||||
|
|
||||||
$row = CcBlockcontentsQuery::create()
|
$row = CcBlockcontentsQuery::create()
|
||||||
->joinWith(CcFilesPeer::OM_CLASS)
|
->joinWith(CcFilesPeer::OM_CLASS)
|
||||||
|
@ -1275,8 +1275,10 @@ SQL;
|
||||||
$isBlockFull = false;
|
$isBlockFull = false;
|
||||||
|
|
||||||
while ($iterator->valid()) {
|
while ($iterator->valid()) {
|
||||||
|
|
||||||
$id = $iterator->current()->getDbId();
|
$id = $iterator->current()->getDbId();
|
||||||
$length = Application_Common_DateHelper::calculateLengthInSeconds($iterator->current()->getDbLength());
|
$fileLength = $iterator->current()->getCueLength();
|
||||||
|
$length = Application_Common_DateHelper::calculateLengthInSeconds($fileLength);
|
||||||
$insertList[] = array('id'=>$id, 'length'=>$length);
|
$insertList[] = array('id'=>$id, 'length'=>$length);
|
||||||
$totalTime += $length;
|
$totalTime += $length;
|
||||||
$totalItems++;
|
$totalItems++;
|
||||||
|
@ -1291,8 +1293,11 @@ SQL;
|
||||||
|
|
||||||
$sizeOfInsert = count($insertList);
|
$sizeOfInsert = count($insertList);
|
||||||
|
|
||||||
// if block is not full and reapeat_track is check, fill up more
|
// if block is not full and repeat_track is check, fill up more
|
||||||
while (!$isBlockFull && $repeat == 1 && $sizeOfInsert > 0) {
|
while (!$isBlockFull && $repeat == 1 && $sizeOfInsert > 0) {
|
||||||
|
Logging::debug("adding repeated tracks.");
|
||||||
|
Logging::debug("total time = " . $totalTime);
|
||||||
|
|
||||||
$randomEleKey = array_rand(array_slice($insertList, 0, $sizeOfInsert));
|
$randomEleKey = array_rand(array_slice($insertList, 0, $sizeOfInsert));
|
||||||
$insertList[] = $insertList[$randomEleKey];
|
$insertList[] = $insertList[$randomEleKey];
|
||||||
$totalTime += $insertList[$randomEleKey]['length'];
|
$totalTime += $insertList[$randomEleKey]['length'];
|
||||||
|
|
|
@ -12,6 +12,20 @@
|
||||||
* @package propel.generator.campcaster
|
* @package propel.generator.campcaster
|
||||||
*/
|
*/
|
||||||
class CcFiles extends BaseCcFiles {
|
class CcFiles extends BaseCcFiles {
|
||||||
|
|
||||||
|
public function getCueLength()
|
||||||
|
{
|
||||||
|
$cuein = $this->getDbCuein();
|
||||||
|
$cueout = $this->getDbCueout();
|
||||||
|
|
||||||
|
$cueinSec = Application_Common_DateHelper::calculateLengthInSeconds($cuein);
|
||||||
|
$cueoutSec = Application_Common_DateHelper::calculateLengthInSeconds($cueout);
|
||||||
|
$lengthSec = bcsub($cueoutSec, $cueinSec, 6);
|
||||||
|
|
||||||
|
$length = Application_Common_DateHelper::secondsToPlaylistTime($lengthSec);
|
||||||
|
|
||||||
|
return $length;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDbLength($format = "H:i:s.u")
|
public function getDbLength($format = "H:i:s.u")
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,11 @@ ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq"
|
||||||
|
|
||||||
export PYTHONPATH=${api_client_path}
|
export PYTHONPATH=${api_client_path}
|
||||||
|
|
||||||
cd /usr/lib/airtime/pypo/bin/liquidsoap_scripts
|
SCRIPT=`readlink -f $0`
|
||||||
|
# Absolute directory this script is in
|
||||||
|
SCRIPTPATH=`dirname $SCRIPT`
|
||||||
|
|
||||||
|
cd $SCRIPTPATH/liquidsoap_scripts
|
||||||
python generate_liquidsoap_cfg.py
|
python generate_liquidsoap_cfg.py
|
||||||
|
|
||||||
exec ${ls_path} ${ls_param} 2>&1
|
exec ${ls_path} ${ls_param} 2>&1
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
from api_clients.api_client import AirtimeApiClient
|
from api_clients.api_client import AirtimeApiClient
|
||||||
|
|
||||||
def generate_liquidsoap_config(ss):
|
def generate_liquidsoap_config(ss):
|
||||||
|
@ -26,10 +27,19 @@ def generate_liquidsoap_config(ss):
|
||||||
|
|
||||||
logging.basicConfig(format='%(message)s')
|
logging.basicConfig(format='%(message)s')
|
||||||
ac = AirtimeApiClient(logging.getLogger())
|
ac = AirtimeApiClient(logging.getLogger())
|
||||||
try:
|
attempts = 0
|
||||||
ss = ac.get_stream_setting()
|
max_attempts = 5
|
||||||
generate_liquidsoap_config(ss)
|
|
||||||
except Exception, e:
|
while True:
|
||||||
logging.error(str(e))
|
try:
|
||||||
print "Unable to connect to the Airtime server."
|
ss = ac.get_stream_setting()
|
||||||
sys.exit(1)
|
generate_liquidsoap_config(ss)
|
||||||
|
break
|
||||||
|
except Exception, e:
|
||||||
|
if attempts == max_attempts:
|
||||||
|
print "Unable to connect to the Airtime server."
|
||||||
|
logging.error(str(e))
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
time.sleep(3)
|
||||||
|
attempts += 1
|
||||||
|
|
Loading…
Reference in New Issue