Merge branch '2.2.x' of dev.sourcefabric.org:airtime into 2.2.x
This commit is contained in:
commit
2bab46a12e
|
@ -713,6 +713,7 @@ SQL;
|
||||||
'end' => $stream_end,
|
'end' => $stream_end,
|
||||||
'uri' => $uri,
|
'uri' => $uri,
|
||||||
'type' => 'stream_buffer_end',
|
'type' => 'stream_buffer_end',
|
||||||
|
'row_id' => $item["id"],
|
||||||
'independent_event' => true
|
'independent_event' => true
|
||||||
);
|
);
|
||||||
self::appendScheduleItem($data, $stream_end, $schedule_item);
|
self::appendScheduleItem($data, $stream_end, $schedule_item);
|
||||||
|
|
|
@ -283,7 +283,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
mod.fnRemove = function(aItems) {
|
mod.fnRemove = function(aItems) {
|
||||||
|
|
||||||
mod.disableUI();
|
mod.disableUI();
|
||||||
if (confirm("Delete selected item(s)?")) {
|
if (confirm("Remove selected scheduled item(s)?")) {
|
||||||
$.post( "/showbuilder/schedule-remove",
|
$.post( "/showbuilder/schedule-remove",
|
||||||
{"items": aItems, "format": "json"},
|
{"items": aItems, "format": "json"},
|
||||||
mod.fnItemCallback
|
mod.fnItemCallback
|
||||||
|
|
|
@ -413,7 +413,7 @@ def create_dynamic_source(uri) =
|
||||||
# We register both source and output
|
# We register both source and output
|
||||||
# in the list of sources
|
# in the list of sources
|
||||||
dyn_sources :=
|
dyn_sources :=
|
||||||
list.append([(uri,s),(uri,active_dyn_out)], !dyn_sources)
|
list.append([(!current_dyn_id, s),(!current_dyn_id, active_dyn_out)], !dyn_sources)
|
||||||
|
|
||||||
notify([("schedule_table_id", !current_dyn_id)])
|
notify([("schedule_table_id", !current_dyn_id)])
|
||||||
"Done!"
|
"Done!"
|
||||||
|
@ -421,7 +421,62 @@ end
|
||||||
|
|
||||||
|
|
||||||
# A function to destroy a dynamic source
|
# A function to destroy a dynamic source
|
||||||
def destroy_dynamic_source_all(uri) =
|
def destroy_dynamic_source(id) =
|
||||||
|
# We need to find the source in the list,
|
||||||
|
# remove it and destroy it. Currently, the language
|
||||||
|
# lacks some nice operators for that so we do it
|
||||||
|
# the functional way
|
||||||
|
|
||||||
|
# This function is executed on every item in the list
|
||||||
|
# of dynamic sources
|
||||||
|
def parse_list(ret, current_element) =
|
||||||
|
# ret is of the form: (matching_sources, remaining_sources)
|
||||||
|
# We extract those two:
|
||||||
|
matching_sources = fst(ret)
|
||||||
|
remaining_sources = snd(ret)
|
||||||
|
|
||||||
|
# current_element is of the form: ("uri", source) so
|
||||||
|
# we check the first element
|
||||||
|
current_id = fst(current_element)
|
||||||
|
if current_id == id then
|
||||||
|
# In this case, we add the source to the list of
|
||||||
|
# matched sources
|
||||||
|
(list.append( [snd(current_element)],
|
||||||
|
matching_sources),
|
||||||
|
remaining_sources)
|
||||||
|
else
|
||||||
|
# In this case, we put the element in the list of remaining
|
||||||
|
# sources
|
||||||
|
(matching_sources,
|
||||||
|
list.append([current_element],
|
||||||
|
remaining_sources))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Now we execute the function:
|
||||||
|
result = list.fold(parse_list, ([], []), !dyn_sources)
|
||||||
|
matching_sources = fst(result)
|
||||||
|
remaining_sources = snd(result)
|
||||||
|
|
||||||
|
# We store the remaining sources in dyn_sources
|
||||||
|
dyn_sources := remaining_sources
|
||||||
|
|
||||||
|
# If no source matched, we return an error
|
||||||
|
if list.length(matching_sources) == 0 then
|
||||||
|
"Error: no matching sources!"
|
||||||
|
else
|
||||||
|
# We stop all sources
|
||||||
|
list.iter(source.shutdown, matching_sources)
|
||||||
|
# And return
|
||||||
|
"Done!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# A function to destroy a dynamic source
|
||||||
|
def destroy_dynamic_source_all() =
|
||||||
# We need to find the source in the list,
|
# We need to find the source in the list,
|
||||||
# remove it and destroy it. Currently, the language
|
# remove it and destroy it. Currently, the language
|
||||||
# lacks some nice operators for that so we do it
|
# lacks some nice operators for that so we do it
|
||||||
|
@ -466,57 +521,3 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# A function to destroy a dynamic source
|
|
||||||
def destroy_dynamic_source(uri) =
|
|
||||||
# We need to find the source in the list,
|
|
||||||
# remove it and destroy it. Currently, the language
|
|
||||||
# lacks some nice operators for that so we do it
|
|
||||||
# the functional way
|
|
||||||
|
|
||||||
# This function is executed on every item in the list
|
|
||||||
# of dynamic sources
|
|
||||||
def parse_list(ret, current_element) =
|
|
||||||
# ret is of the form: (matching_sources, remaining_sources)
|
|
||||||
# We extract those two:
|
|
||||||
matching_sources = fst(ret)
|
|
||||||
remaining_sources = snd(ret)
|
|
||||||
|
|
||||||
# current_element is of the form: ("uri", source) so
|
|
||||||
# we check the first element
|
|
||||||
current_uri = fst(current_element)
|
|
||||||
if current_uri == uri then
|
|
||||||
# In this case, we add the source to the list of
|
|
||||||
# matched sources
|
|
||||||
(list.append( [snd(current_element)],
|
|
||||||
matching_sources),
|
|
||||||
remaining_sources)
|
|
||||||
else
|
|
||||||
# In this case, we put the element in the list of remaining
|
|
||||||
# sources
|
|
||||||
(matching_sources,
|
|
||||||
list.append([current_element],
|
|
||||||
remaining_sources))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Now we execute the function:
|
|
||||||
result = list.fold(parse_list, ([], []), !dyn_sources)
|
|
||||||
matching_sources = fst(result)
|
|
||||||
remaining_sources = snd(result)
|
|
||||||
|
|
||||||
# We store the remaining sources in dyn_sources
|
|
||||||
dyn_sources := remaining_sources
|
|
||||||
|
|
||||||
# If no source matched, we return an error
|
|
||||||
if list.length(matching_sources) == 0 then
|
|
||||||
"Error: no matching sources!"
|
|
||||||
else
|
|
||||||
# We stop all sources
|
|
||||||
list.iter(source.shutdown, matching_sources)
|
|
||||||
# And return
|
|
||||||
"Done!"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -99,17 +99,17 @@ server.register(namespace="dynamic_source",
|
||||||
description="Start a new dynamic source.",
|
description="Start a new dynamic source.",
|
||||||
usage="start <uri>",
|
usage="start <uri>",
|
||||||
"read_start",
|
"read_start",
|
||||||
fun (s) -> begin log("dynamic_source.read_start") create_dynamic_source(s) end)
|
fun (uri) -> begin log("dynamic_source.read_start") create_dynamic_source(uri) end)
|
||||||
server.register(namespace="dynamic_source",
|
server.register(namespace="dynamic_source",
|
||||||
description="Stop a dynamic source.",
|
description="Stop a dynamic source.",
|
||||||
usage="stop <uri>",
|
usage="stop <id>",
|
||||||
"read_stop",
|
"read_stop",
|
||||||
fun (s) -> begin log("dynamic_source.read_stop") destroy_dynamic_source(s) end)
|
fun (s) -> begin log("dynamic_source.read_stop") destroy_dynamic_source(s) end)
|
||||||
server.register(namespace="dynamic_source",
|
server.register(namespace="dynamic_source",
|
||||||
description="Stop a dynamic source.",
|
description="Stop a dynamic source.",
|
||||||
usage="stop <uri>",
|
usage="stop <id>",
|
||||||
"read_stop_all",
|
"read_stop_all",
|
||||||
fun (s) -> begin log("dynamic_source.read_stop") destroy_dynamic_source_all(s) end)
|
fun (s) -> begin log("dynamic_source.read_stop") destroy_dynamic_source_all() end)
|
||||||
|
|
||||||
default = amplify(id="silence_src", 0.00001, noise())
|
default = amplify(id="silence_src", 0.00001, noise())
|
||||||
default = rewrite_metadata([("artist","Airtime"), ("title", "offline")], default)
|
default = rewrite_metadata([("artist","Airtime"), ("title", "offline")], default)
|
||||||
|
|
|
@ -455,6 +455,7 @@ class PypoPush(Thread):
|
||||||
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
|
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
|
||||||
|
|
||||||
msg = 'dynamic_source.id %s\n' % media_item['row_id']
|
msg = 'dynamic_source.id %s\n' % media_item['row_id']
|
||||||
|
self.logger.debug(msg)
|
||||||
tn.write(msg)
|
tn.write(msg)
|
||||||
|
|
||||||
#example: dynamic_source.read_start http://87.230.101.24:80/top100station.mp3
|
#example: dynamic_source.read_start http://87.230.101.24:80/top100station.mp3
|
||||||
|
@ -523,7 +524,7 @@ class PypoPush(Thread):
|
||||||
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
|
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
|
||||||
#dynamic_source.stop http://87.230.101.24:80/top100station.mp3
|
#dynamic_source.stop http://87.230.101.24:80/top100station.mp3
|
||||||
|
|
||||||
msg = 'dynamic_source.read_stop %s\n' % media_item['uri'].encode('latin-1')
|
msg = 'dynamic_source.read_stop %s\n' % media_item['row_id']
|
||||||
self.logger.debug(msg)
|
self.logger.debug(msg)
|
||||||
tn.write(msg)
|
tn.write(msg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue