From 3a1945a818e1af428e42216502799e16cf66f0a9 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 22 Nov 2012 11:40:44 -0500 Subject: [PATCH] CC-4702Webstream: When webstream is playing, it isn't marked as 'media_item_played' in cc_schedule -fixed --- .../application/controllers/ApiController.php | 42 ++++++++++--------- .../pypo/liquidsoap_scripts/ls_script.liq | 5 --- python_apps/pypo/pyponotify.py | 1 + 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 1a1876ce9..89fd93467 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -926,31 +926,33 @@ class ApiController extends Zend_Controller_Action $data_arr = json_decode($data); - if (!is_null($media_id) && isset($data_arr->title) && strlen($data_arr->title) < 1024) { + if (!is_null($media_id)) { + if (isset($data_arr->title) && + strlen($data_arr->title) < 1024) { - $previous_metadata = CcWebstreamMetadataQuery::create() - ->orderByDbStartTime('desc') - ->filterByDbInstanceId($media_id) - ->findOne(); + $previous_metadata = CcWebstreamMetadataQuery::create() + ->orderByDbStartTime('desc') + ->filterByDbInstanceId($media_id) + ->findOne(); - $do_insert = true; - if ($previous_metadata) { - if ($previous_metadata->getDbLiquidsoapData() == $data_arr->title) { - Logging::debug("Duplicate found: ".$data_arr->title); - $do_insert = false; + $do_insert = true; + if ($previous_metadata) { + if ($previous_metadata->getDbLiquidsoapData() == $data_arr->title) { + Logging::debug("Duplicate found: ".$data_arr->title); + $do_insert = false; + } + } + + if ($do_insert) { + $webstream_metadata = new CcWebstreamMetadata(); + $webstream_metadata->setDbInstanceId($media_id); + $webstream_metadata->setDbStartTime(new DateTime("now", new DateTimeZone("UTC"))); + $webstream_metadata->setDbLiquidsoapData($data_arr->title); + $webstream_metadata->save(); } } - - if ($do_insert) { - $webstream_metadata = new CcWebstreamMetadata(); - $webstream_metadata->setDbInstanceId($media_id); - $webstream_metadata->setDbStartTime(new DateTime("now", new DateTimeZone("UTC"))); - $webstream_metadata->setDbLiquidsoapData($data_arr->title); - $webstream_metadata->save(); - } - } else { - throw new Error("Unexpected error. media_id $media_id has a null stream value in cc_schedule!"); + throw new Exception("Null value of media_id"); } $this->view->response = $data; diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 5cec2301b..ac0e380e9 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -53,11 +53,6 @@ http = input.http_restart(id="http") http = cross_http(http_input_id="http",http) stream_queue = http_fallback(http_input_id="http",http=http,default=queue) -#stream_queue = switch(id="stream_queue_switch", track_sensitive=false, -# transitions=[transition, transition], -# [({!webstream_enabled},web_stream), -# ({true}, queue)]) - ignore(output.dummy(stream_queue, fallible=true)) server.register(namespace="vars", diff --git a/python_apps/pypo/pyponotify.py b/python_apps/pypo/pyponotify.py index 9c2f1688c..96b358e9c 100644 --- a/python_apps/pypo/pyponotify.py +++ b/python_apps/pypo/pyponotify.py @@ -114,6 +114,7 @@ class Notify: self.notify_source_status(options.source_name, options.source_status) elif options.webstream: self.notify_webstream_data(options.webstream, options.media_id) + self.notify_media_start_playing(options.media_id) elif options.media_id: self.notify_media_start_playing(options.media_id) elif options.liquidsoap_started: