Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
f3dce46a5a
|
@ -288,7 +288,7 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
//used by caller to determine if the airtime they are running or widgets in use is out of date.
|
||||
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;
|
||||
header("Content-type: text/javascript");
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// If a callback is not given, then just provide the raw JSON.
|
||||
echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result);
|
||||
|
@ -348,11 +348,14 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
public function scheduleAction()
|
||||
{
|
||||
$data = Application_Model_Schedule::getSchedule();
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$data = Application_Model_Schedule::getSchedule();
|
||||
|
||||
echo json_encode($data, JSON_FORCE_OBJECT);
|
||||
$this->_helper->json->sendJson($data, false, true);
|
||||
}
|
||||
|
||||
public function notifyMediaItemStartPlayAction()
|
||||
|
|
|
@ -126,12 +126,12 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
%include "mp3.liq"
|
||||
elsif type == "ogg" then
|
||||
%include "ogg.liq"
|
||||
elsif type == "opus" then
|
||||
%include "opus.liq"
|
||||
elsif type == "aac" then
|
||||
%include "aac.liq"
|
||||
else
|
||||
%include "aacplus.liq"
|
||||
#elsif type == "opus" then
|
||||
# %include "opus.liq"
|
||||
#elsif type == "aac" then
|
||||
# %include "aac.liq"
|
||||
#else
|
||||
# %include "aacplus.liq"
|
||||
end
|
||||
else
|
||||
user_ref = ref user
|
||||
|
@ -165,10 +165,10 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
|
||||
if type == "mp3" then
|
||||
%include "mp3.liq"
|
||||
elsif type == "aac" then
|
||||
%include "aac.liq"
|
||||
else
|
||||
%include "aacplus.liq"
|
||||
#elsif type == "aac" then
|
||||
# %include "aac.liq"
|
||||
#else
|
||||
# %include "aacplus.liq"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class ReplayGainUpdater(Thread):
|
|||
"""
|
||||
The purpose of the class is to query the server for a list of files which
|
||||
do not have a ReplayGain value calculated. This class will iterate over the
|
||||
list calculate the values, update the server and repeat the process until
|
||||
list, calculate the values, update the server and repeat the process until
|
||||
the server reports there are no files left.
|
||||
|
||||
This class will see heavy activity right after a 2.1->2.2 upgrade since 2.2
|
||||
|
|
|
@ -36,15 +36,20 @@ signal.signal(signal.SIGINT, keyboardInterruptHandler)
|
|||
|
||||
POLL_INTERVAL = 1800
|
||||
|
||||
config_static = None
|
||||
|
||||
class PypoFetch(Thread):
|
||||
def __init__(self, pypoFetch_q, pypoPush_q, media_q, telnet_lock, pypo_liquidsoap, config):
|
||||
Thread.__init__(self)
|
||||
global config_static
|
||||
|
||||
self.api_client = api_client.AirtimeApiClient()
|
||||
self.fetch_queue = pypoFetch_q
|
||||
self.push_queue = pypoPush_q
|
||||
self.media_prepare_queue = media_q
|
||||
self.last_update_schedule_timestamp = time.time()
|
||||
self.config = config
|
||||
config_static = config
|
||||
self.listener_timeout = POLL_INTERVAL
|
||||
|
||||
self.telnet_lock = telnet_lock
|
||||
|
@ -102,10 +107,13 @@ class PypoFetch(Thread):
|
|||
self.update_liquidsoap_transition_fade(m['transition_fade'])
|
||||
elif command == 'switch_source':
|
||||
self.logger.info("switch_on_source show command received...")
|
||||
self.switch_source(self.logger, self.telnet_lock, m['sourcename'], m['status'])
|
||||
self.pypo_liquidsoap.\
|
||||
get_telnet_dispatcher().\
|
||||
switch_source(m['sourcename'], m['status'])
|
||||
elif command == 'disconnect_source':
|
||||
self.logger.info("disconnect_on_source show command received...")
|
||||
self.disconnect_source(self.logger, self.telnet_lock, m['sourcename'])
|
||||
self.pypo_liquidsoap.get_telnet_dispatcher().\
|
||||
disconnect_source(m['sourcename'])
|
||||
else:
|
||||
self.logger.info("Unknown command: %s" % command)
|
||||
|
||||
|
@ -123,65 +131,7 @@ class PypoFetch(Thread):
|
|||
self.logger.error("traceback: %s", top)
|
||||
self.logger.error("Exception in handling Message Handler message: %s", e)
|
||||
|
||||
@staticmethod
|
||||
def disconnect_source(logger, lock, sourcename):
|
||||
logger.debug('Disconnecting source: %s', sourcename)
|
||||
command = ""
|
||||
if(sourcename == "master_dj"):
|
||||
command += "master_harbor.kick\n"
|
||||
elif(sourcename == "live_dj"):
|
||||
command += "live_dj_harbor.kick\n"
|
||||
|
||||
try:
|
||||
lock.acquire()
|
||||
tn = telnetlib.Telnet(self.config['ls_host'], self.config['ls_port'])
|
||||
logger.info(command)
|
||||
tn.write(command)
|
||||
tn.write('exit\n')
|
||||
tn.read_all()
|
||||
except Exception, e:
|
||||
logger.error(traceback.format_exc())
|
||||
finally:
|
||||
lock.release()
|
||||
|
||||
@staticmethod
|
||||
def telnet_send(logger, lock, commands):
|
||||
try:
|
||||
lock.acquire()
|
||||
|
||||
tn = telnetlib.Telnet(self.config['ls_host'], self.config['ls_port'])
|
||||
for i in commands:
|
||||
logger.info(i)
|
||||
tn.write(i)
|
||||
|
||||
tn.write('exit\n')
|
||||
tn.read_all()
|
||||
except Exception, e:
|
||||
logger.error(str(e))
|
||||
finally:
|
||||
lock.release()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def switch_source(logger, lock, sourcename, status):
|
||||
logger.debug('Switching source: %s to "%s" status', sourcename, status)
|
||||
command = "streams."
|
||||
if sourcename == "master_dj":
|
||||
command += "master_dj_"
|
||||
elif sourcename == "live_dj":
|
||||
command += "live_dj_"
|
||||
elif sourcename == "scheduled_play":
|
||||
command += "scheduled_play_"
|
||||
|
||||
if status == "on":
|
||||
command += "start\n"
|
||||
else:
|
||||
command += "stop\n"
|
||||
|
||||
PypoFetch.telnet_send(logger, lock, [command])
|
||||
|
||||
|
||||
#TODO: Merge this with switch_source
|
||||
def switch_source_temp(self, sourcename, status):
|
||||
self.logger.debug('Switching source: %s to "%s" status', sourcename, status)
|
||||
command = "streams."
|
||||
|
@ -222,7 +172,7 @@ class PypoFetch(Thread):
|
|||
commands.append(('vars.stream_metadata_type %s\n' % stream_format).encode('utf-8'))
|
||||
commands.append(('vars.station_name %s\n' % station_name).encode('utf-8'))
|
||||
commands.append(('vars.default_dj_fade %s\n' % fade).encode('utf-8'))
|
||||
PypoFetch.telnet_send(self.logger, self.telnet_lock, commands)
|
||||
self.pypo_liquidsoap.get_telnet_dispatcher().telnet_send(commands)
|
||||
|
||||
def restart_liquidsoap(self):
|
||||
try:
|
||||
|
|
|
@ -23,6 +23,9 @@ class PypoLiquidsoap():
|
|||
port,\
|
||||
self.liq_queue_tracker.keys())
|
||||
|
||||
def get_telnet_dispatcher(self):
|
||||
return self.telnet_liquidsoap
|
||||
|
||||
|
||||
def play(self, media_item):
|
||||
if media_item["type"] == eventtypes.FILE:
|
||||
|
@ -67,9 +70,9 @@ class PypoLiquidsoap():
|
|||
|
||||
def handle_event_type(self, media_item):
|
||||
if media_item['event_type'] == "kick_out":
|
||||
PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj")
|
||||
self.telnet_liquidsoap.disconnect_source("live_dj")
|
||||
elif media_item['event_type'] == "switch_off":
|
||||
PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off")
|
||||
self.telnet_liquidsoap.switch_source("live_dj", "off")
|
||||
|
||||
|
||||
def is_media_item_finished(self, media_item):
|
||||
|
|
|
@ -193,6 +193,60 @@ class TelnetLiquidsoap:
|
|||
finally:
|
||||
self.telnet_lock.release()
|
||||
|
||||
def disconnect_source(self, sourcename):
|
||||
self.logger.debug('Disconnecting source: %s', sourcename)
|
||||
command = ""
|
||||
if(sourcename == "master_dj"):
|
||||
command += "master_harbor.kick\n"
|
||||
elif(sourcename == "live_dj"):
|
||||
command += "live_dj_harbor.kick\n"
|
||||
|
||||
try:
|
||||
self.telnet_lock.acquire()
|
||||
tn = telnetlib.Telnet(self.ls_host, self.ls_port)
|
||||
self.logger.info(command)
|
||||
tn.write(command)
|
||||
tn.write('exit\n')
|
||||
tn.read_all()
|
||||
except Exception, e:
|
||||
self.logger.error(traceback.format_exc())
|
||||
finally:
|
||||
self.telnet_lock.release()
|
||||
|
||||
def telnet_send(self, commands):
|
||||
try:
|
||||
self.telnet_lock.acquire()
|
||||
|
||||
tn = telnetlib.Telnet(self.ls_host, self.ls_port)
|
||||
for i in commands:
|
||||
self.logger.info(i)
|
||||
tn.write(i)
|
||||
|
||||
tn.write('exit\n')
|
||||
tn.read_all()
|
||||
except Exception, e:
|
||||
self.logger.error(str(e))
|
||||
finally:
|
||||
self.telnet_lock.release()
|
||||
|
||||
|
||||
def switch_source(self, sourcename, status):
|
||||
self.logger.debug('Switching source: %s to "%s" status', sourcename, status)
|
||||
command = "streams."
|
||||
if sourcename == "master_dj":
|
||||
command += "master_dj_"
|
||||
elif sourcename == "live_dj":
|
||||
command += "live_dj_"
|
||||
elif sourcename == "scheduled_play":
|
||||
command += "scheduled_play_"
|
||||
|
||||
if status == "on":
|
||||
command += "start\n"
|
||||
else:
|
||||
command += "stop\n"
|
||||
|
||||
self.telnet_send([command])
|
||||
|
||||
class DummyTelnetLiquidsoap:
|
||||
|
||||
def __init__(self, telnet_lock, logger):
|
||||
|
|
Loading…
Reference in New Issue