From 63b89043b605219363de07067cbd0b3206437ad7 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 1 Aug 2012 14:51:56 -0400 Subject: [PATCH] CC-1665: Scheduled stream rebroadcasting and recording on-air light works with streams now --- airtime_mvc/application/models/Schedule.php | 6 +++++ .../pypo/liquidsoap_scripts/ls_lib.liq | 27 ++++++++++++------- .../pypo/liquidsoap_scripts/ls_script.liq | 6 +++++ python_apps/pypo/pypopush.py | 4 +++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 88b3c49b3..abdf9591e 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -665,6 +665,12 @@ class Application_Model_Schedule //time of this event is the "end" time of the stream minus 1 second. $dt = new DateTime($item["end"], new DateTimeZone('UTC')); $dt->sub(new DateInterval("PT1S")); + + //make sure the webstream doesn't play past the end time of the show + if ($dt->getTimestamp() > $showEndDateTime->getTimestamp()) { + $dt = $showEndDateTime; + } + $stream_end = Application_Model_Schedule::AirtimeTimeToPypoTime($dt->format("Y-m-d H:i:s")); $data["media"][$stream_end] = array( diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index 9fe471108..18e2290e6 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -235,20 +235,27 @@ dyn_out = output.icecast(%wav, mount="test-harbor", fallible=true) +def set_dynamic_source_id(id) = + current_dyn_id := id + #"Done!" + string_of(!current_dyn_id) +end + # Function to create a playlist source and output it. def create_dynamic_source(uri) = - # The playlist source - s = input.http(uri) + # The playlist source + s = input.http(uri) - # The output - active_dyn_out = dyn_out(s) + # The output + active_dyn_out = dyn_out(s) - # We register both source and output - # in the list of sources - dyn_sources := - list.append( [(uri,s),(uri,active_dyn_out)], - !dyn_sources ) - "Done!" + # We register both source and output + # in the list of sources + dyn_sources := + list.append([(uri,s),(uri,active_dyn_out)], !dyn_sources) + + notify([("schedule_table_id", !current_dyn_id)]) + "Done!" end # A function to destroy a dynamic source diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 83d4605fd..b7c2c4460 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -21,6 +21,7 @@ set("harbor.bind_addr", "0.0.0.0") #TODO: Need to create a randomized password for every instance web_stream = input.harbor("test-harbor",port=8999,password="hackme") +current_dyn_id = ref '' pypo_data = ref '0' stream_metadata_type = ref 0 @@ -53,6 +54,11 @@ server.register(namespace="vars", "station_name", fun (s) -> begin station_name server.register(namespace="vars", "bootup_time", fun (s) -> begin time := s s end) server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}" end) server.register(namespace="vars", "default_dj_fade", fun (s) -> begin default_dj_fade := float_of_string(s) s end) +server.register(namespace="dynamic_source", + description="Set the cc_schedule row id", + usage="id ", + "id", + set_dynamic_source_id) server.register(namespace="dynamic_source", description="Start a new dynamic source.", usage="start ", diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 628133f59..93d527d40 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -374,6 +374,10 @@ class PypoPush(Thread): tn = telnetlib.Telnet(LS_HOST, LS_PORT) #dynamic_source.start http://87.230.101.24:80/top100station.mp3 + msg = 'dynamic_source.id %s\n' % media_item['row_id'] + tn.write(msg) + + #TODO: DO we need this? msg = 'streams.scheduled_play_start\n' tn.write(msg) msg = 'dynamic_source.start %s\n' % media_item['uri'].encode('latin-1')