Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
88ba36601f
53 changed files with 4139 additions and 862 deletions
|
@ -16,7 +16,7 @@ import base64
|
|||
import traceback
|
||||
from configobj import ConfigObj
|
||||
|
||||
AIRTIME_VERSION = "2.3.1"
|
||||
AIRTIME_VERSION = "2.4.0"
|
||||
|
||||
|
||||
# TODO : Place these functions in some common module. Right now, media
|
||||
|
@ -127,22 +127,31 @@ class ApiRequest(object):
|
|||
self.__req = None
|
||||
if logger is None: self.logger = logging
|
||||
else: self.logger = logger
|
||||
|
||||
def __call__(self,_post_data=None, **kwargs):
|
||||
final_url = self.url.params(**kwargs).url()
|
||||
if _post_data is not None: _post_data = urllib.urlencode(_post_data)
|
||||
self.logger.debug(final_url)
|
||||
try:
|
||||
req = urllib2.Request(final_url, _post_data)
|
||||
response = urllib2.urlopen(req).read()
|
||||
f = urllib2.urlopen(req)
|
||||
content_type = f.info().getheader('Content-Type')
|
||||
response = f.read()
|
||||
except Exception, e:
|
||||
self.logger.error('Exception: %s', e)
|
||||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
raise
|
||||
# Ghetto hack for now because we don't the content type we are getting
|
||||
# (Pointless to look at mime since it's not being set correctly always)
|
||||
|
||||
try:
|
||||
return json.loads(response)
|
||||
if content_type == 'application/json':
|
||||
data = json.loads(response)
|
||||
self.logger.debug(data)
|
||||
return data
|
||||
else:
|
||||
raise InvalidContentType()
|
||||
except Exception:
|
||||
self.logger.error(response)
|
||||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
raise
|
||||
|
||||
def req(self, *args, **kwargs):
|
||||
|
@ -508,3 +517,7 @@ class AirtimeApiClient(object):
|
|||
except Exception, e:
|
||||
#TODO
|
||||
self.logger.error(str(e))
|
||||
|
||||
|
||||
class InvalidContentType(Exception):
|
||||
pass
|
||||
|
|
|
@ -148,7 +148,8 @@ class MetadataElement(Loggable):
|
|||
if self.__max_length != -1:
|
||||
r = truncate_to_length(r, self.__max_length)
|
||||
if self.__max_value != -1:
|
||||
r = truncate_to_value(r, self.__max_value)
|
||||
try: r = truncate_to_value(r, self.__max_value)
|
||||
except ValueError, e: r = ''
|
||||
return r
|
||||
|
||||
def normalize_mutagen(path):
|
||||
|
|
|
@ -245,7 +245,7 @@ if __name__ == '__main__':
|
|||
pf.daemon = True
|
||||
pf.start()
|
||||
|
||||
pp = PypoPush(pypoPush_q, telnet_lock, pypo_liquidsoap)
|
||||
pp = PypoPush(pypoPush_q, telnet_lock, pypo_liquidsoap, config)
|
||||
pp.daemon = True
|
||||
pp.start()
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ class PypoFetch(Thread):
|
|||
|
||||
line = line.strip()
|
||||
|
||||
if not len(line) or line[0] == "#"
|
||||
if not len(line) or line[0] == "#":
|
||||
continue
|
||||
|
||||
try:
|
||||
|
|
|
@ -57,8 +57,7 @@ class PypoPush(Thread):
|
|||
self.queue_id = 0
|
||||
|
||||
self.future_scheduled_queue = Queue()
|
||||
self.pypo_liquidsoap = PypoLiquidsoap(self.logger, telnet_lock,\
|
||||
config['ls_host'], config['ls_port'])
|
||||
self.pypo_liquidsoap = pypo_liquidsoap
|
||||
|
||||
self.plq = PypoLiqQueue(self.future_scheduled_queue, \
|
||||
self.pypo_liquidsoap, \
|
||||
|
|
|
@ -2,9 +2,9 @@ import telnetlib
|
|||
|
||||
def create_liquidsoap_annotation(media):
|
||||
# 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",' + \
|
||||
return ('annotate:media_id="%s",liq_start_next="0",liq_fade_in="%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":%s') % \
|
||||
(media['id'],
|
||||
float(media['fade_in']) / 1000,
|
||||
float(media['fade_out']) / 1000,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue