-initial changes for CC-1944
This commit is contained in:
parent
9759efc6cf
commit
2346be671e
6 changed files with 82 additions and 43 deletions
51
pypo/scripts/lib.liq
Normal file
51
pypo/scripts/lib.liq
Normal file
|
@ -0,0 +1,51 @@
|
|||
def notify(m)
|
||||
system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}")
|
||||
print("./notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}")
|
||||
end
|
||||
|
||||
# A function applied to each metadata chunk
|
||||
def append_title(m) =
|
||||
if !stream_metadata_type == 1 then
|
||||
[("artist","#{!show_name} - #{m['title']}")]
|
||||
elsif !stream_metadata_type == 2 then
|
||||
[("artist", ""), ("title", !show_name)]
|
||||
elsif !stream_metadata_type == 3 then
|
||||
[("artist",!station_name), ("title", !show_name)]
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def crossfade(s)
|
||||
s = fade.in(type="log", s)
|
||||
s = fade.out(type="log", s)
|
||||
fader = fun (a,b) -> add(normalize=false,[b,a])
|
||||
cross(fader,s)
|
||||
end
|
||||
|
||||
# Define a transition that fades out the
|
||||
# old source, adds a single, and then
|
||||
# plays the new source
|
||||
def to_live(old,new) =
|
||||
# Fade out old source
|
||||
old = fade.final(old)
|
||||
# Compose this in sequence with
|
||||
# the new source
|
||||
sequence([old,new])
|
||||
end
|
||||
|
||||
# Add a skip function to a source
|
||||
# when it does not have one
|
||||
# by default
|
||||
def add_skip_command(s)
|
||||
# A command to skip
|
||||
def skip(_)
|
||||
source.skip(s)
|
||||
"Done!"
|
||||
end
|
||||
# Register the command:
|
||||
server.register(namespace="source",
|
||||
usage="skip",
|
||||
description="Skip the current song.",
|
||||
"skip",skip)
|
||||
end
|
|
@ -10,48 +10,18 @@ queue = audio_to_stereo(queue)
|
|||
|
||||
pypo_data = ref '0'
|
||||
web_stream_enabled = ref false
|
||||
stream_metadata_type = ref 0
|
||||
station_name = ref ''
|
||||
show_name = ref ''
|
||||
|
||||
def notify(m)
|
||||
system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}")
|
||||
print("./notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}")
|
||||
end
|
||||
%include "lib.liq"
|
||||
|
||||
def crossfade(s)
|
||||
s = fade.in(type="log", s)
|
||||
s = fade.out(type="log", s)
|
||||
fader = fun (a,b) -> add(normalize=false,[b,a])
|
||||
cross(fader,s)
|
||||
end
|
||||
server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end)
|
||||
server.register(namespace="vars", "web_stream_enabled", fun (s) -> begin web_stream_enabled := (s == "true") string_of(!web_stream_enabled) end)
|
||||
server.register(namespace="vars", "stream_metadata_type", fun (s) -> begin stream_metadata_type := int_of_string(s) s end)
|
||||
server.register(namespace="vars", "show_name", fun (s) -> begin show_name := s s end)
|
||||
server.register(namespace="vars", "station_name", fun (s) -> begin station_name := s s end)
|
||||
|
||||
# Define a transition that fades out the
|
||||
# old source, adds a single, and then
|
||||
# plays the new source
|
||||
def to_live(old,new) =
|
||||
# Fade out old source
|
||||
old = fade.final(old)
|
||||
# Compose this in sequence with
|
||||
# the new source
|
||||
sequence([old,new])
|
||||
end
|
||||
|
||||
# Add a skip function to a source
|
||||
# when it does not have one
|
||||
# by default
|
||||
def add_skip_command(s)
|
||||
# A command to skip
|
||||
def skip(_)
|
||||
source.skip(s)
|
||||
"Done!"
|
||||
end
|
||||
# Register the command:
|
||||
server.register(namespace="source",
|
||||
usage="skip",
|
||||
description="Skip the current song.",
|
||||
"skip",skip)
|
||||
end
|
||||
|
||||
server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end)
|
||||
server.register(namespace="vars", "web_stream_enabled", fun (s) -> begin web_stream_enabled := (s == "true") string_of(!web_stream_enabled) end)
|
||||
|
||||
default = single(conservative=true, "/opt/pypo/files/basic/silence.mp3")
|
||||
default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)
|
||||
|
@ -60,7 +30,6 @@ s = fallback(track_sensitive=false, [queue, default])
|
|||
|
||||
s = on_metadata(notify, s)
|
||||
s = crossfade(s)
|
||||
|
||||
# Attach a skip command to the source s:
|
||||
add_skip_command(s)
|
||||
|
||||
|
@ -78,6 +47,9 @@ s = switch(track_sensitive = false,
|
|||
]
|
||||
)
|
||||
|
||||
s = map_metadata(append_title, s)
|
||||
|
||||
|
||||
if output_sound_device then
|
||||
out_device = out(s)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue