Commit 5da362f9 authored by Gottfried Gaisbauer's avatar Gottfried Gaisbauer
Browse files

push to liquidsoap (http,fs)

parent 4fcc02b6
This diff is collapsed.
......@@ -24,13 +24,13 @@ db_host="localhost"
# if you have no idea what to do here => set use_alsa to "n", then pulseaudio is used
use_alsa="y"
# alsa_buffer => int
#alsa_buffer="16000"
alsa_buffer="16000"
# alsa_buffer_length => int
alsa_buffer_length="5"
alsa_buffer_length="7"
# alsa_periods => int
alsa_periods="0"
# frame_duration => double
frame_duration="0.35"
frame_duration="0.4"
# frame_size => int
frame_size=""
......
......@@ -316,9 +316,9 @@ class AuraCalendarService(threading.Thread):
if playlist_id == 1: # station fallback
schedule_entries = simplejson.loads('{"playlist_id":1,"entries":[{"source":"pool://easylistening","artist":"station wide fallback pool","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":""}]}')
if playlist_id == 2: # playlist to play for schedule #1 => linein
schedule_entries = simplejson.loads('{"playlist_id":2,"entries":[{"entry_start":"'+(datetime.now()+timedelta(hours=0)).strftime('%Y-%m-%d %H:00:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=0)).strftime('%Y-%m-%d %H:05:00')+'","source":"/var/audio/jingles/jingle.flac","artist":"jingle","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":"1999"},{"entry_start":"'+(datetime.now()+timedelta(hours=0)).strftime('%Y-%m-%d %H:05:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=1)).strftime('%Y-%m-%d %H:00:00')+'","source":"linein://0","artist":"live","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":""}]}')
schedule_entries = simplejson.loads('{"playlist_id":2,"entries":[{"entry_start":"'+(datetime.now()+timedelta(hours=0)).strftime('%Y-%m-%d %H:00:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=0)).strftime('%Y-%m-%d %H:05:00')+'","source":"file:///var/audio/fallback/music.flac","artist":"jingle","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":"1999"},{"entry_start":"'+(datetime.now()+timedelta(hours=0)).strftime('%Y-%m-%d %H:05:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=1)).strftime('%Y-%m-%d %H:00:00')+'","source":"linein://0","artist":"live","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":""}]}')
if playlist_id == 4: # playlist to play for schedule #2 => from file system
schedule_entries = simplejson.loads('{"playlist_id":4,"entries":[{"entry_start":"'+(datetime.now()+timedelta(hours=1)).strftime('%Y-%m-%d %H:00:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=1)).strftime('%Y-%m-%d %H:05:00')+'","source":"file:///var/audio/jingles/jingle.flac","artist":"jingle","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":"1999"},{"entry_start":"'+(datetime.now()+timedelta(hours=1)).strftime('%Y-%m-%d %H:05:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=2)).strftime('%Y-%m-%d %H:00:00')+'","source":"file:///var/audio/preprod.flac","artist":"live","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":""}]}')
schedule_entries = simplejson.loads('{"playlist_id":4,"entries":[{"entry_start":"'+(datetime.now()+timedelta(hours=1)).strftime('%Y-%m-%d %H:00:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=1)).strftime('%Y-%m-%d %H:05:00')+'","source":"file:///var/audio/fallback/music.flac","artist":"jingle","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":"1999"},{"entry_start":"'+(datetime.now()+timedelta(hours=1)).strftime('%Y-%m-%d %H:05:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=2)).strftime('%Y-%m-%d %H:00:00')+'","source":"file:///var/audio/fallback/NightmaresOnWax/DJ-Kicks/01 - Type - Slow Process.flac","artist":"live","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":""}]}')
if playlist_id == 6: # playlist to play for schedule #3 => http stream
schedule_entries = simplejson.loads('{"playlist_id":6,"entries":[{"entry_start":"'+(datetime.now()+timedelta(hours=2)).strftime('%Y-%m-%d %H:00:00')+'","entry_end":"'+(datetime.now()+timedelta(hours=3)).strftime('%Y-%m-%d %H:00:00')+'","source":"http://stream.fro.at:80/fro-128.ogg","artist":"Stream Übernahme von Radio FRO","track":"","albumname":"","genre":"","tracknum":"","cdnum":"","year":""}]}')
if playlist_id == 12: # schedule #0 fallback
......@@ -328,16 +328,17 @@ class AuraCalendarService(threading.Thread):
if playlist_id == 32: # schedule #2 fallback
schedule_entries = simplejson.loads('{"playlist_id":22,"entries":[{"source":"pool:///rock"}]}')
if playlist_id == 92: # show fallback for schedule #0
schedule_entries = simplejson.loads('{"playlist_id":92,"entries":[{"source":"file:///var/audio/playlist/playlist1.m3u"}]}')
schedule_entries = simplejson.loads('{"playlist_id":92,"entries":[{"source":"file:///var/audio/playlist/yarn-01-03.m3u8"}]}')
if playlist_id == 102: # show fallback for schedule #1
schedule_entries = simplejson.loads('{"playlist_id":102,"entries":[{"source":"file:///var/audio/playlist/playlist2.m3u"}]}')
schedule_entries = simplejson.loads('{"playlist_id":102,"entries":[{"source":"file:///var/audio/playlist/yarn-04-06.m3u8"}]}')
if playlist_id == 112: # show fallback for schedule #2
schedule_entries = simplejson.loads('{"playlist_id":112,"entries":[{"source":"file:///var/audio/playlist/playlist3.m3u"}]}')
schedule_entries = simplejson.loads('{"playlist_id":112,"entries":[{"source":"file:///var/audio/playlist/yarn-07-10.m3u8"}]}')
for entry in schedule_entries["entries"]:
if entry["source"].startswith("file"):
if not os.path.isfile(entry["source"]):
print("WARNING: File", entry["source"], "does not exist!")
e = entry["source"][7:]
if not os.path.isfile(e):
print("WARNING: File", e, "does not exist!")
# elif entry["source"].startswith("pool"):
fetched_schedule_entries.append(schedule_entries)
......@@ -415,7 +416,7 @@ class AuraCalendarService(threading.Thread):
# ------------------------------------------------------------------------------------------ #
def get_data(self):
params = self.dataURL[self.dataURL.find('&'):]
print("params: "+params)
#print("params: "+params)
# ------------------------------------------------------------------------------------------ #
def stop(self):
......
......@@ -9,6 +9,7 @@ from sqlalchemy import orm, func, Boolean, Column, Date, DateTime, Float, Intege
from sqlalchemy.orm import relationship
from sqlalchemy.sql.expression import false
from libraries.database.database import db
from libraries.enum.scheduleentrytypes import ScheduleEntryTypes
class AuraDatabaseModel:
......@@ -127,6 +128,7 @@ class ScheduleEntry(db.Model, AuraDatabaseModel):
entry_start_unix = 0
entry_end_unix = 0
programme_index = -1
type = None
schedule = relationship("Schedule", foreign_keys=[schedule_id], lazy="joined")
......@@ -134,13 +136,25 @@ class ScheduleEntry(db.Model, AuraDatabaseModel):
super(ScheduleEntry, self).__init__(**kwargs)
self.calc_unix_times()
@orm.reconstructor
def reconstructor(self):
self.calc_unix_times()
self.set_entry_type()
def calc_unix_times(self):
if self.entry_start is not None:
self.entry_start_unix = time.mktime(self.entry_start.timetuple())
if self.entry_end is not None:
self.entry_end_unix = time.mktime(self.entry_end.timetuple())
def set_entry_type(self):
if self.source.startswith("http"):
self.type = ScheduleEntryTypes.HTTP
if self.source.startswith("pool") or self.source.startswith("playlist") or self.source.startswith("file") :
self.type = ScheduleEntryTypes.FILESYSTEM
if self.source.startswith("live"):
self.type = ScheduleEntryTypes.LIVE
# ------------------------------------------------------------------------------------------ #
@staticmethod
......
from enum import Enum
class ScheduleEntryTypes(Enum):
HTTP = "http"
LIVE = "live"
FILESYSTEM = "fs"
......@@ -107,27 +107,25 @@ class LiquidSoapClient:
# ------------------------------------------------------------------------------------------ #
def read(self):
"""
Vom Socket lesen und anschließend quit senden, um den Server zu veranlassen, die Verbindung schließen
read from socket and store return value in self.message
@rtype: string
@return: Die Antwort des Liquidsoap-Servers
@return: The answer of liquidsoap server
"""
if self.connected:
ret = self.read_all()
ret = ret.splitlines()
ret = self.read_all().splitlines()
try:
# print("pop from empty list?")
# print(ret)
ret.pop() # pop 'END' out
# print(ret)
# print("yes")
self.message = str.join('\n', ret)
# self.message = str(b'\n'.join(ret))
last = ret.pop()
if last == 'Bye!':
ret.append(last)
elif last != "END":
print("got no end from liquidsoap")
self.message = str.join("\r\n", ret)
except Exception as e:
print(e)
# self.client.sendall('quit\n')
return self.message
# ------------------------------------------------------------------------------------------ #
......
......@@ -14,6 +14,7 @@ from libraries.enum.consolecolor import TerminalColors
from libraries.exceptions.auraexceptions import LQConnectionError
from libraries.database.broadcasts import TrackService
from libraries.exceptions.exception_logger import ExceptionLogger
from libraries.enum.scheduleentrytypes import ScheduleEntryTypes
class LiquidSoapCommunicator(ExceptionLogger):
......@@ -34,6 +35,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
@type lqs_recsocket: string
@param lqs_recsocket: Liquidsoap Recorder Socket
"""
self.config = config
self.debug = config.get("debug")
self.lqc = LiquidSoapPlayerClient(config, "simplestmixer.sock")
self.lqcr = LiquidSoapRecorderClient(config, "record.sock")
......@@ -85,10 +87,10 @@ class LiquidSoapCommunicator(ExceptionLogger):
gets active channel from programme
:return:
"""
active_source = self.scheduler.get_active_source()
if active_source == "":
active_entry = self.scheduler.get_active_entry()
if active_entry is None:
return ""
return self.channels.index(active_source)
return active_entry.type
# ------------------------------------------------------------------------------------------ #
def get_mixer_status(self):
......@@ -110,21 +112,38 @@ class LiquidSoapCommunicator(ExceptionLogger):
return inputstate
# ------------------------------------------------------------------------------------------ #
def activate(self, entry, input_type):
if self.scheduler.get_active_source() == input_type:
def activate(self, entry):
# active_source = self.scheduler.get_active_entry().type
# print(active_source)
if self.scheduler.get_active_entry().type == entry.type:
print(TerminalColors.OK_PINK.value + "LiquidSoapCommunicator " + entry.type.value + " already active! Time: " + str(datetime.datetime.now()) + TerminalColors.ENDC.value)
self.enable_transaction(True)
if entry.type == ScheduleEntryTypes.FILESYSTEM:
self.playlist_push(entry.source)
if entry.type == ScheduleEntryTypes.HTTP:
self.set_http_url(entry.source)
self.disable_transaction(True)
self.insert_track_service_entry(entry)
print(TerminalColors.OK_PINK.value + "LiquidSoapCommunicator " + input_type + " already active! Time: " + str(datetime.datetime.now()) + TerminalColors.ENDC.value)
else:
print(TerminalColors.OK_PINK.value + "LiquidSoapCommunicator is activating " + input_type + "! Time: " + str(datetime.datetime.now()) + TerminalColors.ENDC.value)
print(TerminalColors.OK_PINK.value + "LiquidSoapCommunicator is activating " + entry.type.value + "! Time: " + str(datetime.datetime.now()) + TerminalColors.ENDC.value)
self.enable_transaction(True)
others = self.all_inputs_but(input_type)
if entry.type == ScheduleEntryTypes.FILESYSTEM:
self.playlist_push(entry.source)
if entry.type == ScheduleEntryTypes.HTTP:
self.set_http_url(entry.source)
others = self.all_inputs_but(entry.type.value)
for o in others:
self.channel_volume(o, 0)
self.channel_volume(input_type, entry.volume)
self.channel_volume(entry.type.value, entry.volume)
self.disable_transaction(True)
self.insert_track_service_entry(entry)
self.playlist_insert()
#self.playlist_insert()
# ------------------------------------------------------------------------------------------ #
def insert_track_service_entry(self, schedule_entry):
......@@ -137,8 +156,8 @@ class LiquidSoapCommunicator(ExceptionLogger):
# ------------------------------------------------------------------------------------------ #
def all_inputs_but(self, input_type):
activemixer_copy = self.get_all_channels().copy() # get_active_mixer().copy()
print("holding ", activemixer_copy)
activemixer_copy = self.get_all_channels().copy()
try:
activemixer_copy.remove(input_type)
except ValueError:
......@@ -165,7 +184,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
# ------------------------------------------------------------------------------------------ #
def init_player(self):
LiquidSoapInitThread(self, self.lqc).start()
LiquidSoapInitThread(self).start()
return "Started LiquidSoapInitThread!"
# ------------------------------------------------------------------------------------------ #
......@@ -180,7 +199,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
@return: Die Antwort des Liquidsoap-Servers
"""
channels = self.__send_lqc_command__(self.lqc, 'listChannels')
channels = self.__send_lqc_command__(self.lqc, 'list_channels')
if not isinstance(channels, list):
self.warning('01')
......@@ -323,7 +342,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
if channel == 'playlist':
channel = 'common'
channels = self.__send_lqc_command__(self.lqc, 'listChannels', False)
channels = self.__send_lqc_command__(self.lqc, 'list_channels', False)
index = channels.index(channel)
message = self.__send_lqc_command__(self.lqc, 'deactivate', str(index))
......@@ -348,7 +367,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
if channel == 'playlist':
channel = 'common'
channels = self.__send_lqc_command__(self.lqc, 'listChannels', False)
channels = self.__send_lqc_command__(self.lqc, 'list_channels', False)
index = channels.index(channel)
# a activate channel
......@@ -394,7 +413,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
track['title'] = 'unknown'
data['tracks'].extend([track])
channels = self.__send_lqc_command__(self.lqc, 'listChannels')
channels = self.__send_lqc_command__(self.lqc, 'list_channels')
"""
now get channels state
......@@ -482,7 +501,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
"""
# Liquidsoap Kommando
channels = self.__send_lqc_command__(self.lqc, 'listChannels')
channels = self.__send_lqc_command__(self.lqc, 'list_channels')
foundChannel = ''
if not isinstance(channels, list):
......@@ -502,6 +521,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
self.notifyClient()
# ------------------------------------------------------------------------------------------ #
def channel_activate(self, channel, activate):
channels = self.get_all_channels()
......@@ -527,7 +547,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
@param volume: Lautstärke von 1-100
"""
# Liquidsoap Kommando
#channels = self.__sendLqcCommand__(self.lqc, 'listChannels', False)
#channels = self.__sendLqcCommand__(self.lqc, 'list_channels', False)
channels = self.get_all_channels()
try:
......@@ -577,7 +597,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
if channel == 'playlist':
channel = 'common'
channels = self.__send_lqc_command__(self.lqc, 'listChannels', False)
channels = self.__send_lqc_command__(self.lqc, 'list_channels', False)
index = channels.index(channel)
state_data = {}
......@@ -628,7 +648,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
"""
# Liquidsoap Kommando
channels = self.__send_lqc_command__(self.lqc, 'listChannels')
channels = self.__send_lqc_command__(self.lqc, 'list_channels')
if not isinstance(channels, list):
self.error('02')
......@@ -780,7 +800,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
if when == 'now':
# immediately skip all playing channels
# and activate the playlist channel
channels = self.__send_lqc_command__(self.lqc, 'listChannels')
channels = self.__send_lqc_command__(self.lqc, 'list_channels')
if not isinstance(channels, list):
self.error('03')
elif len(channels) < 1:
......@@ -803,6 +823,10 @@ class LiquidSoapCommunicator(ExceptionLogger):
self.notifyClient()
# ------------------------------------------------------------------------------------------ #
def set_http_url(self, uri):
return self.__send_lqc_command__(self.lqc, 'http', 'url', uri)
# ------------------------------------------------------------------------------------------ #
def playlist_push(self, uri):
"""
......@@ -810,14 +834,8 @@ class LiquidSoapCommunicator(ExceptionLogger):
@type uri: str
@param uri: Die Uri
"""
data = self.__send_lqc_command__(self.lqc, 'push', uri)
if not self._check_result(data):
self.info('01')
else:
self.success('00')
self.notifyClient()
return self.__send_lqc_command__(self.lqc, 'fs', 'push', uri)
# self.notifyClient()
# ------------------------------------------------------------------------------------------ #
def playlist_remove(self, pos):
......@@ -971,10 +989,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
result = func(command, *args)
if self.debug:
if len(args) == 0:
print("LiquidSoapCommunicator got response " + str(result))
else:
print("LiquidSoapCommunicator got response " + str(result))
print("LiquidSoapCommunicator got response " + str(result))
# say byebye
if not self.transaction:
......
......@@ -9,16 +9,17 @@ class LiquidSoapInitThread(threading.Thread):
socket = None
liquidsoapcommunicator = None
def __init__(self, liquidsoapcommunicator, socket):
def __init__(self, liquidsoapcommunicator):
threading.Thread.__init__(self)
self.socket = socket
self.liquidsoapcommunicator = liquidsoapcommunicator
def run(self):
try:
# sleep needed, because the socket is created to slow by liquidsoap
time.sleep(5)
# enable lqs transaction
self.liquidsoapcommunicator.enable_transaction(True)
# reset channels and reload them
......@@ -26,29 +27,26 @@ class LiquidSoapInitThread(threading.Thread):
channels = self.liquidsoapcommunicator.get_all_channels()
# set every volume to 0
cnt = 0
for c in channels:
#self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "volume", cnt, "0")
self.liquidsoapcommunicator.channel_volume(c, "0")
cnt = cnt + 1
self.liquidsoapcommunicator.playlist_push(self.liquidsoapcommunicator.config.get("install_dir")+"/configuration/blank.flac")
self.liquidsoapcommunicator.set_http_url("http://stream.fro.at/fro-128.ogg")
# select all channels
cnt = 0
for c in channels:
self.liquidsoapcommunicator.channel_activate(c, True)
#self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "select", cnt, "true")
cnt = cnt + 1
# thats hacky => the cracklings stop after 5 seconds after restarting the liquidsoap server
time.sleep(3)
activechannel = self.liquidsoapcommunicator.get_active_channel()
if self.liquidsoapcommunicator.debug > 2:
print("LiquidSoapInitThread sets activechannel: "+str(activechannel))
if activechannel != "":
self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "volume", activechannel, 100)
if activechannel != "" and activechannel is not None:
self.liquidsoapcommunicator.channel_volume(activechannel.value, 100)
#self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "volume", activechannel, 100)
# self.liquidsoapcommunicator.close_conn(self.socket)
self.liquidsoapcommunicator.disable_transaction(True)
except LQConnectionError as e:
print("Liquidsoap connection ERROR! Restart LQ Server!")
......
......@@ -18,7 +18,31 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
if len(args) == 2:
return self.mixerselect(args[0], args[1])
return "LiquidSoapPlayerClient does not understand "+command+str(args)
return "LiquidSoapPlayerClient does not understand mixer."+command+str(args)
# ------------------------------------------------------------------------------------------ #
def http(self, command, *args):
if command == "url":
return self.set_http_url(*args)
return "LiquidSoapPlayerClient does not understand http." + command + str(args)
# ------------------------------------------------------------------------------------------ #
def fs(self, command, *args):
if command == "push":
return self.fs_push(*args)
return "LiquidSoapPlayerClient does not understand fs." + command + str(args)
# ------------------------------------------------------------------------------------------ #
def fs_push(self, uri):
self.command('fs', 'push', uri)
return self.message
# ------------------------------------------------------------------------------------------ #
def set_http_url(self, uri):
self.command('http', 'url', uri)
return self.message
# ------------------------------------------------------------------------------------------ #
def mixerinputs(self):
......@@ -172,20 +196,6 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
self.command('flush', namespace)
return self.message
# ------------------------------------------------------------------------------------------ #
def push(self, uri, namespace="playlist"):
"""
Track einfügen und abspielen (wenn source aktiv ist)
@type uri: string
@param uri: Uri eines Audios
@type namespace: string
@param namespace: Namespace der Source
@rtype: string
@return: Die Antwort des Liquidsoap-Servers
"""
self.command('push', namespace, str(uri))
return self.message
# ------------------------------------------------------------------------------------------ #
def playlistData(self):
"""
......
......@@ -12,7 +12,7 @@ ini = read_ini("/etc/aura/aura.ini")
#input_fs = single(id="fs", "/var/audio/fallback/output.flac")
input_fs = request.queue(id="fs")
input_http = input.http(id="http", "http://stream.fro.at/fro-128.ogg")
linein_alsa = input.alsa(id="linein", device="hw:0", bufferize = false)
linein_alsa = input.alsa(id="live", device="hw:0", bufferize = false)
# create fallbacks
timeslot_fallback = fallback_create(skip=true, "timeslot_fallback", create_timeslot_fallback)
......@@ -25,7 +25,7 @@ mixer = mix(id="mixer", [input_fs, input_http, linein_alsa])
# output source with station_fallback
output_source = fallback(track_sensitive=false, [mixer, show_fallback, timeslot_fallback, station_fallback])
# clock.unify([output_source, mixer, show_fallback, timeslot_fallback, station_fallback])
clock.unify([output_source, mixer, show_fallback, timeslot_fallback, station_fallback])
# create output
output.alsa(id="lineout", device="hw:0", bufferize = false, output_source)
......
This diff is collapsed.
......@@ -187,7 +187,7 @@ class AuraScheduler(ExceptionLogger):
self.start()
# ------------------------------------------------------------------------------------------ #
def get_active_source(self):
def get_active_entry(self):
now_unix = time.mktime(datetime.datetime.now().timetuple())
actsource = ""
lastentry = None
......@@ -202,22 +202,22 @@ class AuraScheduler(ExceptionLogger):
# check if lastentry is set and if act entry is in the future
if lastentry is not None and entry.entry_start_unix > now_unix:
# return lastentry if so
actsource = entry.source
break
return entry # actsource = entry.source
# break
lastentry = entry
if actsource.startswith("file") or actsource.startswith("pool") or actsource.startswith("playlist"):
print("AuraScheduler found upcoming source '" + str(entry.__dict__) + "'! returning: fs")
return "fs"
elif actsource.startswith("http"):
print("AuraScheduler found upcoming source '" + str(entry.__dict__) + "'! returning: http")
return "http"
elif actsource.startswith("linein"):
print("AuraScheduler found upcoming source '" + str(entry.__dict__) + "'! returning: linein")
return "linein"
# if actsource.startswith("file") or actsource.startswith("pool") or actsource.startswith("playlist"):
# print("AuraScheduler found upcoming source '" + str(entry.__dict__) + "'! returning: fs")
# return "fs"
# elif actsource.startswith("http"):
# print("AuraScheduler found upcoming source '" + str(entry.__dict__) + "'! returning: http")
# return "http"
# elif actsource.startswith("linein"):
# print("AuraScheduler found upcoming source '" + str(entry.__dict__) + "'! returning: linein")
# return "linein"
return ""
return None
# ------------------------------------------------------------------------------------------ #
def load_programme_from_db(self, silent=False):
......@@ -242,17 +242,17 @@ class AuraScheduler(ExceptionLogger):
# create the activation threads and run them after <diff> seconds
if entry.source.startswith("linein"):
self.add_or_update_timer(entry, diff, self.liquidsoapcommunicator.activate, "linein")
self.add_or_update_timer(entry, diff, self.liquidsoapcommunicator.activate)
elif entry.source.startswith("http"):
if first_stream_in_programme:
self.liquidsoapcommunicator.next_stream_source(entry.source)
first_stream_in_programme = False
self.add_or_update_timer(entry, diff, self.liquidsoapcommunicator.activate, "http")
self.add_or_update_timer(entry, diff, self.liquidsoapcommunicator.activate)
elif entry.source.startswith("file"):
self.add_or_update_timer(entry, diff, self.liquidsoapcommunicator.activate, "fs")
self.add_or_update_timer(entry, diff, self.liquidsoapcommunicator.activate)
else:
print("WARNING: Cannot understand source '" + entry.source + "' from " + str(entry.__dict__))
......@@ -262,7 +262,7 @@ class AuraScheduler(ExceptionLogger):
print(entry.__dict__)
# ------------------------------------------------------------------------------------------ #
def add_or_update_timer(self, entry, diff, func, type):
def add_or_update_timer(self, entry, diff, func):
# check if something is planned at given time
planned_timer = self.is_something_planned_at_time(entry.entry_start)
......@@ -276,13 +276,13 @@ class AuraScheduler(ExceptionLogger):
self.stop_timer(planned_timer)
# and create a new one
self.create_timer(entry, diff, func, type)
self.create_timer(entry, diff, func)
# if the playlist id's do not differ => do nothing, they are the same
# if nothing is planned at given time, create a new timer
else:
self.create_timer(entry, diff, func, type)
self.create_timer(entry, diff, func)
# ------------------------------------------------------------------------------------------ #
def stop_timer(self, timer):
......@@ -292,8 +292,8 @@ class AuraScheduler(ExceptionLogger):
self.message_timer.remove(timer)