From 989f040603994dd60aa53766c8a6204e9560aed0 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 7 Sep 2012 11:41:20 -0400 Subject: [PATCH 01/23] CC-4371: input.harbor for rebroadcasting webstreams has hardcoded password. -fixed --- python_apps/pypo/liquidsoap_scripts/ls_lib.liq | 2 +- python_apps/pypo/liquidsoap_scripts/ls_script.liq | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index a3b3fc319..328ea21ab 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -393,7 +393,7 @@ end dyn_out = output.icecast(%wav, host="localhost", port=8999, - password="hackme", + password=stream_harbor_pass, mount="test-harbor", fallible=true) diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index b7a6d41d7..7b04210b4 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -36,9 +36,11 @@ s2_namespace = ref '' s3_namespace = ref '' just_switched = ref false +stream_harbor_pass = list.hd(get_process_lines('pwgen -s -N 1 -n 20')) + %include "ls_lib.liq" -web_stream = input.harbor("test-harbor", port=8999, password="hackme") +web_stream = input.harbor("test-harbor", port=8999, password=stream_harbor_pass) web_stream = on_metadata(notify_stream, web_stream) queue = on_metadata(notify, queue) From 089e8965520215ccdf1dbd3d6dc1c70fe97ef5a2 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 7 Sep 2012 14:34:58 -0400 Subject: [PATCH 02/23] fix camelCase of function --- airtime_mvc/application/controllers/ApiController.php | 2 +- airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php | 2 +- airtime_mvc/application/models/Schedule.php | 2 +- airtime_mvc/application/models/tests/populator.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index cd0ed19d1..aaed18773 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -336,7 +336,7 @@ class ApiController extends Zend_Controller_Action $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - $data = Application_Model_Schedule::GetScheduledPlaylists(); + $data = Application_Model_Schedule::getScheduledPlaylists(); echo json_encode($data, JSON_FORCE_OBJECT); } diff --git a/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php b/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php index c1ea6b1ba..c00679df8 100644 --- a/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php +++ b/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php @@ -5,7 +5,7 @@ class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract public function dispatchLoopShutdown() { if (Application_Model_RabbitMq::$doPush) { - $md = array('schedule' => Application_Model_Schedule::GetScheduledPlaylists()); + $md = array('schedule' => Application_Model_Schedule::getScheduledPlaylists()); Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md); if (!isset($_SERVER['AIRTIME_SRV'])) { Application_Model_RabbitMq::SendMessageToShowRecorder("update_recorder_schedule"); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index a78431bf1..a560e79e9 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -570,7 +570,7 @@ SQL; return $rows; } - public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null) + public static function getScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null) { global $CC_CONFIG; diff --git a/airtime_mvc/application/models/tests/populator.php b/airtime_mvc/application/models/tests/populator.php index 1ad1b2806..cd9386aaa 100644 --- a/airtime_mvc/application/models/tests/populator.php +++ b/airtime_mvc/application/models/tests/populator.php @@ -99,7 +99,7 @@ while ($showTime < $endDate) { } if (Application_Model_RabbitMq::$doPush) { - $md = array('schedule' => Application_Model_Schedule::GetScheduledPlaylists()); + $md = array('schedule' => Application_Model_Schedule::getScheduledPlaylists()); Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md); } From 3c0541f13816052fd163a921f4c076b53ec46b99 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 7 Sep 2012 16:50:33 -0400 Subject: [PATCH 03/23] fix function camelcase --- airtime_mvc/application/controllers/ShowbuilderController.php | 2 +- airtime_mvc/application/models/Schedule.php | 2 +- airtime_mvc/application/models/ShowBuilder.php | 2 +- airtime_mvc/application/models/tests/SchedulerTests.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 6f02a1467..7e3d94865 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -274,7 +274,7 @@ class ShowbuilderController extends Zend_Controller_Action $opts = array("myShows" => $my_shows, "showFilter" => $show_filter); $showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts); - $data = $showBuilder->GetItems(); + $data = $showBuilder->getItems(); $this->view->schedule = $data["schedule"]; $this->view->instances = $data["showInstances"]; $this->view->timestamp = $current_time; diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index a560e79e9..407fbd561 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -511,7 +511,7 @@ SQL; * Returns null if nothing found, else an array of associative * arrays representing each row. */ - public static function GetItems($p_startTime, $p_endTime) + public static function getItems($p_startTime, $p_endTime) { global $CC_CONFIG; diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index ebad18ca3..b73a341d0 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -386,7 +386,7 @@ class Application_Model_ShowBuilder return $outdated; } - public function GetItems() + public function getItems() { $current_id = -1; $display_items = array(); diff --git a/airtime_mvc/application/models/tests/SchedulerTests.php b/airtime_mvc/application/models/tests/SchedulerTests.php index 40235e786..0122ee981 100644 --- a/airtime_mvc/application/models/tests/SchedulerTests.php +++ b/airtime_mvc/application/models/tests/SchedulerTests.php @@ -104,7 +104,7 @@ class SchedulerTests extends PHPUnit_TestCase { $groupId1 = $i1->add('2008-01-01 12:00:00.000', $this->storedFile->getId()); $i2 = new Application_Model_ScheduleGroup(); $i2->addAfter($groupId1, $this->storedFile->getId()); - $items = Application_Model_Schedule::GetItems("2008-01-01", "2008-01-02"); + $items = Application_Model_Schedule::getItems("2008-01-01", "2008-01-02"); if (count($items) != 2) { $this->fail("Wrong number of items returned."); return; From 101c28f9c312359ff53d8f2734c111bdb6cca6e1 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 7 Sep 2012 16:50:52 -0400 Subject: [PATCH 04/23] remove unused variable (PHP 5.4 warning) --- airtime_mvc/application/models/Preference.php | 1 - 1 file changed, 1 deletion(-) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index bd5d98898..a2f563b11 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -132,7 +132,6 @@ class Application_Model_Preference public static function GetHeadTitle() { $title = self::getValue("station_name"); - $defaultNamespace->title = $title; if (strlen($title) > 0) $title .= " - "; From 6c8d6025183ee391d42865728cefcf119a94bb66 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 7 Sep 2012 16:51:51 -0400 Subject: [PATCH 05/23] CC-4371: input.harbor for rebroadcasting webstreams has hardcoded password. pwgen dependency --- install_full/ubuntu/airtime-full-install | 3 ++- install_full/ubuntu/airtime-full-install-nginx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index af135b124..57faff468 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -52,7 +52,8 @@ php-pear php5-gd postgresql odbc-postgresql python libsoundtouch-ocaml \ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \ libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \ php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \ -libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools +libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools \ +pwgen #install packages with --force-yes option (this is useful in the case #of Debian, where these packages are unauthorized) diff --git a/install_full/ubuntu/airtime-full-install-nginx b/install_full/ubuntu/airtime-full-install-nginx index c89e81198..c00e3f159 100755 --- a/install_full/ubuntu/airtime-full-install-nginx +++ b/install_full/ubuntu/airtime-full-install-nginx @@ -43,7 +43,8 @@ php-pear php5-gd postgresql odbc-postgresql python libsoundtouch-ocaml \ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \ libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \ php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \ -libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools +libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools \ +pwgen #install packages with --force-yes option (this is useful in the case #of Debian, where these packages are unauthorized) From d20c4502267d012cae699523f32e4d303809c718 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 7 Sep 2012 17:38:24 -0400 Subject: [PATCH 06/23] CC-4370: Transitioning between two webstreams a hiccup in the stream is audible -some major refactoring before fixing this problem --- .../application/controllers/ApiController.php | 2 +- .../controllers/plugins/RabbitMqPlugin.php | 2 +- airtime_mvc/application/models/Schedule.php | 247 +++++++++++------- .../application/models/tests/populator.php | 2 +- python_apps/pypo/pypopush.py | 8 +- .../pypo/test/airtime-schedule-insert.php | 2 +- 6 files changed, 161 insertions(+), 102 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index aaed18773..f103ef459 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -336,7 +336,7 @@ class ApiController extends Zend_Controller_Action $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - $data = Application_Model_Schedule::getScheduledPlaylists(); + $data = Application_Model_Schedule::getSchedule(); echo json_encode($data, JSON_FORCE_OBJECT); } diff --git a/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php b/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php index c00679df8..346bfdccc 100644 --- a/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php +++ b/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php @@ -5,7 +5,7 @@ class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract public function dispatchLoopShutdown() { if (Application_Model_RabbitMq::$doPush) { - $md = array('schedule' => Application_Model_Schedule::getScheduledPlaylists()); + $md = array('schedule' => Application_Model_Schedule::getSchedule()); Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md); if (!isset($_SERVER['AIRTIME_SRV'])) { Application_Model_RabbitMq::SendMessageToShowRecorder("update_recorder_schedule"); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 407fbd561..f97b21325 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -570,7 +570,127 @@ SQL; return $rows; } - public static function getScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null) + private static function createInputHarborKickTimes(&$data, $range_start, $range_end) + { + $utcTimeZone = new DateTimeZone("UTC"); + $kick_times = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ($range_start, $range_end); + foreach ($kick_times as $kick_time_info) { + $kick_time = $kick_time_info['ends']; + $temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade()); + // we round down transition time since PHP cannot handle millisecond. We need to + // handle this better in the future + $transition_time = intval($temp[0]); + $switchOffDataTime = new DateTime($kick_time, $utcTimeZone); + $switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S')); + $switch_off_time = $switch_off_time->format("Y-m-d H:i:s"); + + $kick_start = self::AirtimeTimeToPypoTime($kick_time); + $data["media"][$kick_start]['start'] = $kick_start; + $data["media"][$kick_start]['end'] = $kick_start; + $data["media"][$kick_start]['event_type'] = "kick_out"; + $data["media"][$kick_start]['type'] = "event"; + $data["media"][$kick_start]['independent_event'] = true; + + if ($kick_time !== $switch_off_time) { + $switch_start = self::AirtimeTimeToPypoTime($switch_off_time); + $data["media"][$switch_start]['start'] = $switch_start; + $data["media"][$switch_start]['end'] = $switch_start; + $data["media"][$switch_start]['event_type'] = "switch_off"; + $data["media"][$switch_start]['independent_event'] = true; + } + } + } + + private static function createFileScheduleEvent(&$data, $item, $media_id) + { + $start = self::AirtimeTimeToPypoTime($item["start"]); + $end = self::AirtimeTimeToPypoTime($item["end"]); + + $schedule_item = array( + 'id' => $media_id, + 'type' => 'file', + 'row_id' => $item["id"], + 'uri' => $uri, + 'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]), + 'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]), + 'cue_in' => Application_Common_DateHelper::CalculateLengthInSeconds($item["cue_in"]), + 'cue_out' => Application_Common_DateHelper::CalculateLengthInSeconds($item["cue_out"]), + 'start' => $start, + 'end' => $end, + 'show_name' => $showName, + 'replay_gain' => is_null($item["replay_gain"]) ? "0": $item["replay_gain"], + 'independent_event' => true + ); + $data["media"][$start] = $schedule_item; + } + + private static function createStreamScheduleEvent(&$data, $item, $media_id) + { + $start = self::AirtimeTimeToPypoTime($item["start"]); + $end = self::AirtimeTimeToPypoTime($item["end"]); + + //create an event to start stream buffering 5 seconds ahead of the streams actual time. + $buffer_start = new DateTime($item["start"], new DateTimeZone('UTC')); + $buffer_start->sub(new DateInterval("PT5S")); + + $stream_buffer_start = self::AirtimeTimeToPypoTime($buffer_start->format("Y-m-d H:i:s")); + + $schedule_item = array( + 'start' => $stream_buffer_start, + 'end' => $stream_buffer_start, + 'uri' => $uri, + 'row_id' => $item["id"], + 'type' => 'stream_buffer_start', + 'independent_event' => true + ); + + //TODO: Make sure no other media is being overwritten! + $data["media"][$stream_buffer_start] = $schedule_item; + $schedule_item = array( + 'id' => $media_id, + 'type' => 'stream_output_start', + 'row_id' => $item["id"], + 'uri' => $uri, + 'start' => $start, + 'end' => $end, + 'show_name' => $showName, + 'independent_event' => true + ); + $data["media"][$start] = $schedule_item; + + //since a stream never ends we have to insert an additional "kick stream" event. The "start" + //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 = self::AirtimeTimeToPypoTime($dt->format("Y-m-d H:i:s")); + + $schedule_item = array( + 'start' => $stream_end, + 'end' => $stream_end, + 'uri' => $uri, + 'type' => 'stream_buffer_end', + 'independent_event' => true + ); + $data["media"][$stream_end] = $schedule_item; + + + $schedule_item = array( + 'start' => $stream_end, + 'end' => $stream_end, + 'uri' => $uri, + 'type' => 'stream_output_end', + 'independent_event' => true + ); + $data["media"][$stream_end] = $schedule_item; + } + + private static function getRangeStartAndEnd($p_fromDateTime, $p_toDateTime) { global $CC_CONFIG; @@ -600,8 +720,13 @@ SQL; $range_end = Application_Model_Schedule::PypoTimeToAirtimeTime($p_toDateTime); } - // Scheduler wants everything in a playlist - $items = self::GetItems($range_start, $range_end); + return array($range_start, $range_end); + } + + public static function getSchedule($p_fromDateTime = null, $p_toDateTime = null) + { + + list($range_start, $range_end) = self::getRangeStartAndEnd($p_fromDateTime, $p_toDateTime); $data = array(); $utcTimeZone = new DateTimeZone("UTC"); @@ -609,33 +734,9 @@ SQL; $data["status"] = array(); $data["media"] = array(); - $kick_times = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ($range_start, $range_end); - foreach ($kick_times as $kick_time_info) { - $kick_time = $kick_time_info['ends']; - $temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade()); - // we round down transition time since PHP cannot handle millisecond. We need to - // handle this better in the future - $transition_time = intval($temp[0]); - $switchOffDataTime = new DateTime($kick_time, $utcTimeZone); - $switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S')); - $switch_off_time = $switch_off_time->format("Y-m-d H:i:s"); - - $kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time); - $data["media"][$kick_start]['start'] = $kick_start; - $data["media"][$kick_start]['end'] = $kick_start; - $data["media"][$kick_start]['event_type'] = "kick_out"; - $data["media"][$kick_start]['type'] = "event"; - $data["media"][$kick_start]['independent_event'] = true; - - if ($kick_time !== $switch_off_time) { - $switch_start = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time); - $data["media"][$switch_start]['start'] = $switch_start; - $data["media"][$switch_start]['end'] = $switch_start; - $data["media"][$switch_start]['event_type'] = "switch_off"; - $data["media"][$switch_start]['independent_event'] = true; - } - } + self::createInputHarborKickTimes($data, $range_start, $range_end); + $items = self::getItems($range_start, $range_end); foreach ($items as $item) { $showInstance = CcShowInstancesQuery::create()->findPK($item["instance_id"]); @@ -648,11 +749,10 @@ SQL; $trackEndDateTime = new DateTime($item["end"], $utcTimeZone); if ($trackStartDateTime->getTimestamp() > $showEndDateTime->getTimestamp()) { + //do not send any tracks that start past their show's end time continue; } - /* Note: cue_out and end are always the same. */ - /* TODO: Not all tracks will have "show_end" */ if ($trackEndDateTime->getTimestamp() > $showEndDateTime->getTimestamp()) { $di = $trackStartDateTime->diff($showEndDateTime); @@ -665,78 +765,37 @@ SQL; $media_id = $item['file_id']; $storedFile = Application_Model_StoredFile::Recall($media_id); $uri = $storedFile->getFilePath(); - $type = "file"; - $independent_event = false; + self::createFileScheduleEvent($data, $item, $media_id, $uri); } elseif (!is_null($item['stream_id'])) { //row is type "webstream" $media_id = $item['stream_id']; $uri = $item['url']; - $type = "stream"; - $independent_event = true; - } - - $start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]); - $end = Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"]); - - $data["media"][$start] = array( - 'id' => $media_id, - 'type' => $type, - 'row_id' => $item["id"], - 'uri' => $uri, - 'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]), - 'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]), - 'cue_in' => Application_Common_DateHelper::CalculateLengthInSeconds($item["cue_in"]), - 'cue_out' => Application_Common_DateHelper::CalculateLengthInSeconds($item["cue_out"]), - 'start' => $start, - 'end' => $end, - 'show_name' => $showName, - 'replay_gain' => is_null($item["replay_gain"]) ? "0": $item["replay_gain"], - 'independent_event' => $independent_event - ); - - if ($type == "stream") { - //create an event to start stream buffering 5 seconds ahead of the streams actual time. - $buffer_start = new DateTime($item["start"], new DateTimeZone('UTC')); - $buffer_start->sub(new DateInterval("PT5S")); - - $stream_buffer_start = Application_Model_Schedule::AirtimeTimeToPypoTime($buffer_start->format("Y-m-d H:i:s")); - - //TODO: Make sure no other media is being overwritten! - $data["media"][$stream_buffer_start] = array( - 'start' => $stream_buffer_start, - 'end' => $stream_buffer_start, - 'uri' => $uri, - 'row_id' => $item["id"], - 'type' => 'stream_buffer_start', - 'independent_event' => true - ); - - - //since a stream never ends we have to insert an additional "kick stream" event. The "start" - //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( - 'start' => $stream_end, - 'end' => $stream_end, - 'uri' => $uri, - 'type' => 'stream_end', - 'independent_event' => true - ); + self::createStreamScheduleEvent($data, $item, $media_id, $uri); } } - return $data; } + /* + private static function collapseEvents($data) + { + $keys = array_keys($data); + + for ($i = 0, $len = count($keys); $i < $len; $i++) { + $cur = $data[$keys[$i]]; + $next = null; + if ($i+1 < $len) { + $next = $data[$keys[$i+1]]; + } + + if ($cur['type'] == 'stream_buffer_end' && !is_null($next) && $next['type'] == 'stream_buffer_start') { + unset($data[$keys[$i]]); + } + + } + } + */ + public static function deleteAll() { global $CC_CONFIG; diff --git a/airtime_mvc/application/models/tests/populator.php b/airtime_mvc/application/models/tests/populator.php index cd9386aaa..3b85d76bb 100644 --- a/airtime_mvc/application/models/tests/populator.php +++ b/airtime_mvc/application/models/tests/populator.php @@ -99,7 +99,7 @@ while ($showTime < $endDate) { } if (Application_Model_RabbitMq::$doPush) { - $md = array('schedule' => Application_Model_Schedule::getScheduledPlaylists()); + $md = array('schedule' => Application_Model_Schedule::getSchedule()); Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md); } diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index d11b52a50..5a5350823 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -40,7 +40,7 @@ except Exception, e: sys.exit() def is_stream(media_item): - return media_item['type'] == 'stream' + return media_item['type'] == 'stream_output_start' def is_file(media_item): return media_item['type'] == 'file' @@ -211,7 +211,7 @@ class PypoPush(Thread): queue. """ file_chain = filter(lambda item: (item["type"] == "file"), current_event_chain) - stream_chain = filter(lambda item: (item["type"] == "stream"), current_event_chain) + stream_chain = filter(lambda item: (item["type"] == "stream_output_start"), current_event_chain) self.logger.debug(self.current_stream_info) self.logger.debug(current_event_chain) @@ -427,13 +427,13 @@ class PypoPush(Thread): PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off") elif media_item['type'] == 'stream_buffer_start': self.start_web_stream_buffer(media_item) - elif media_item['type'] == "stream": + elif media_item['type'] == "stream_output_start": if media_item['row_id'] != self.current_prebuffering_stream_id: #this is called if the stream wasn't scheduled sufficiently ahead of time #so that the prebuffering stage could take effect. Let's do the prebuffering now. self.start_web_stream_buffer(media_item) self.start_web_stream(media_item) - elif media_item['type'] == "stream_end": + elif media_item['type'] == "stream_buffer_end": self.stop_web_stream(media_item) except Exception, e: self.logger.error('Pypo Push Exception: %s', e) diff --git a/python_apps/pypo/test/airtime-schedule-insert.php b/python_apps/pypo/test/airtime-schedule-insert.php index 70c1f38c7..fe2dc97fe 100644 --- a/python_apps/pypo/test/airtime-schedule-insert.php +++ b/python_apps/pypo/test/airtime-schedule-insert.php @@ -78,7 +78,7 @@ echo "Removing everything from the scheduler between $startTime and $endTime..." $scheduleClear = Schedule::isScheduleEmptyInRange($startTime, "01:00:00"); if (!$scheduleClear) { echo "\nERROR: Schedule could not be cleared.\n\n"; - var_dump(Schedule::GetItems($startTime, $endTime)); + var_dump(Schedule::getItems($startTime, $endTime)); exit; } echo "done.\n"; From a3d4b8c722c35dcd50611b2c17350988bc98a031 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:05:30 -0400 Subject: [PATCH 07/23] Todo for consistency. --- .../application/models/ShowInstance.php | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index afbacdadf..906f59ff9 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -167,26 +167,33 @@ class Application_Model_ShowInstance $con = Propel::getConnection(); $instance_id = $this->getShowInstanceId(); - $sql = "SELECT starts from cc_schedule" - ." WHERE instance_id = $instance_id" - ." ORDER BY starts" - ." LIMIT 1"; - - $scheduleStarts = $con->query($sql)->fetchColumn(0); + $sql = << $instance_id ), 'column' ); if ($scheduleStarts) { $scheduleStartsEpoch = strtotime($scheduleStarts); - $showStartsEpoch = strtotime($this->getShowInstanceStart()); + $showStartsEpoch = strtotime($this->getShowInstanceStart()); $diff = $showStartsEpoch - $scheduleStartsEpoch; if ($diff != 0) { - $sql = "UPDATE cc_schedule" - ." SET starts = starts + INTERVAL '$diff' second," - ." ends = ends + INTERVAL '$diff' second" - ." WHERE instance_id = $instance_id"; - - $con->exec($sql); + $sql = << $diff, + ':diff2' => $diff, + ':instanceId' => $instance_id ), 'execute'); } } Application_Model_RabbitMq::PushSchedule(); From 737c3fcbae84702bf1134b8e51df49ca3ca9ee83 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:06:11 -0400 Subject: [PATCH 08/23] Todo for consistency. --- airtime_mvc/application/models/ShowInstance.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 906f59ff9..1e71510d7 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -22,6 +22,8 @@ class Application_Model_ShowInstance return $this->_showInstance->getDbShowId(); } + /* TODO: A little inconsistent because other models have a getId() method + to get PK --RG */ public function getShowInstanceId() { return $this->_instanceId; From 57aae73074309179fb26e4b3e0f760263f69ac6b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:06:34 -0400 Subject: [PATCH 09/23] cc-4347: PDO'd: GetLastShowInstance --- .../application/models/ShowInstance.php | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 1e71510d7..ef2521ad5 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -754,22 +754,17 @@ SQL; public static function GetLastShowInstance($p_timeNow) { - global $CC_CONFIG; - $con = Propel::getConnection(); + $sql = << $p_timeNow ), 'column' ); - $sql = "SELECT si.id" - ." FROM $CC_CONFIG[showInstances] si" - ." WHERE si.ends < TIMESTAMP '$p_timeNow'" - ." AND si.modified_instance = 'f'" - ." ORDER BY si.ends DESC" - ." LIMIT 1"; - - $id = $con->query($sql)->fetchColumn(0); - if ($id) { - return new Application_Model_ShowInstance($id); - } else { - return null; - } + return ($id ? new Application_Model_ShowInstance($id) : null ); } public static function GetCurrentShowInstance($p_timeNow) From 8c3be7393a7336552140a81171fc6dfbae61f823 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:17:45 -0400 Subject: [PATCH 10/23] cc-4347: GetCurrentShowInstance got PDO nuked. --- .../application/models/ShowInstance.php | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index ef2521ad5..d3ee829ac 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -769,29 +769,26 @@ SQL; public static function GetCurrentShowInstance($p_timeNow) { - global $CC_CONFIG; - $con = Propel::getConnection(); - /* Orderby si.starts descending, because in some cases * we can have multiple shows overlapping each other. In * this case, the show that started later is the one that * is actually playing, and so this is the one we want. */ - $sql = "SELECT si.id" - ." FROM $CC_CONFIG[showInstances] si" - ." WHERE si.starts <= TIMESTAMP '$p_timeNow'" - ." AND si.ends > TIMESTAMP '$p_timeNow'" - ." AND si.modified_instance = 'f'" - ." ORDER BY si.starts DESC" - ." LIMIT 1"; + $sql = << :timeNow2::TIMESTAMP + AND si.modified_instance = 'f' +ORDER BY si.starts DESC LIMIT 1 +SQL; - $id = $con->query($sql)->fetchColumn(0); - if ($id) { - return new Application_Model_ShowInstance($id); - } else { - return null; - } + $id = Application_Common_Database( $sql, array( + ':timeNow1' => $p_timeNow, + ':timeNow2' => $p_timeNow ), 'column'); + + return ( $id ? new Application_Model_ShowInstance($id) : null ); } public static function GetNextShowInstance($p_timeNow) From de86b904a5ba16fc98422d8c159a788fc74be677 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:25:21 -0400 Subject: [PATCH 11/23] Fixed extra cast. --- airtime_mvc/application/models/Show.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 38c6cbf91..8214f4c03 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1643,7 +1643,7 @@ SQL; $start_string = $start_timestamp->format("Y-m-d H:i:s"); $end_string = $end_timestamp->format("Y-m-d H:i:s"); if ($onlyRecord) { - $sql .= " AND (si1.starts >= :start::TIMESTAMP AND si1.starts < timestamp :end::TIMESTAMP)"; + $sql .= " AND (si1.starts >= :start::TIMESTAMP AND si1.starts < :end::TIMESTAMP)"; $sql .= " AND (si1.record = 1)"; return Application_Common_Database::prepareAndExecute( $sql, From 53de942c2b393df1fbaed3253e1868a4f43b8651 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:25:44 -0400 Subject: [PATCH 12/23] cc-4347: GetNextShowInstance PDO'd. --- .../application/models/ShowInstance.php | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index d3ee829ac..238b08f27 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -793,22 +793,17 @@ SQL; public static function GetNextShowInstance($p_timeNow) { - global $CC_CONFIG; - $con = Propel::getConnection(); - - $sql = "SELECT si.id" - ." FROM $CC_CONFIG[showInstances] si" - ." WHERE si.starts > TIMESTAMP '$p_timeNow'" - ." AND si.modified_instance = 'f'" - ." ORDER BY si.starts" - ." LIMIT 1"; - - $id = $con->query($sql)->fetchColumn(0); - if ($id) { - return new Application_Model_ShowInstance($id); - } else { - return null; - } + $sql = << :timeNow::TIMESTAMP +AND si.modified_instance = 'f' +ORDER BY si.starts +LIMIT 1 +SQL; + $id = Application_Common_Database::prepareAndExecute( $sql, + array( 'timeNow' => $p_timeNow ), 'column' ); + return ( $id ? new Application_Model_ShowInstance($id) : null ); } // returns number of show instances that ends later than $day From 375e89169e7c4f74e54fc5025ae84d1f26d42cde Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:27:39 -0400 Subject: [PATCH 13/23] Removed code duplication --- airtime_mvc/application/models/ShowInstance.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 238b08f27..1c8c66783 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -833,10 +833,6 @@ SQL; public function isRepeating() { - if ($this->getShow()->isRepeating()) { - return true; - } else { - return false; - } + return $this->getShow()->isRepeating(); } } From dcf3b4c3de43ec9f4695f3d01ac6d60c79ce1cff Mon Sep 17 00:00:00 2001 From: James Date: Mon, 10 Sep 2012 11:28:35 -0400 Subject: [PATCH 14/23] CC-4383: Fatal error in phone_home_stat script (2.2.0 dev) - fixed --- utils/phone_home_stat.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/phone_home_stat.php b/utils/phone_home_stat.php index f720f0dd0..d01a736c1 100644 --- a/utils/phone_home_stat.php +++ b/utils/phone_home_stat.php @@ -35,6 +35,14 @@ get_include_path(), realpath($CC_CONFIG['phpDir'] . '/library') ))); +function __autoload($classname){ + global $CC_CONFIG; + $info = explode('_', $classname); + if (isset($info[2])) { + $filename = $info[2].".php"; + require_once($CC_CONFIG['phpDir'].'/application/models/'.$filename); + } +} require_once($CC_CONFIG['phpDir'].'/application/models/User.php'); require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php'); require_once($CC_CONFIG['phpDir'].'/application/models/Playlist.php'); From e2c2f67fbb51882101e7e5b46b3e44abf26b216b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:29:28 -0400 Subject: [PATCH 15/23] cc-4347: GetShowInstanceCount() pdo'd --- airtime_mvc/application/models/ShowInstance.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 1c8c66783..c19d8c3b7 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -809,11 +809,13 @@ SQL; // returns number of show instances that ends later than $day public static function GetShowInstanceCount($day) { - global $CC_CONFIG; - $con = Propel::getConnection(); - $sql = "SELECT count(*) as cnt FROM $CC_CONFIG[showInstances] WHERE ends < '$day'"; - - return $con->query($sql)->fetchColumn(0); + $sql = << $day ), 'column' ); } // this returns end timestamp of all shows that are in the range and has live DJ set up From 3df4c8d65ad78abd2b956aef79d033c8674eee87 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:39:22 -0400 Subject: [PATCH 16/23] cc-4347: deleteRebroadcasts and GetEndTimeOfNextShowWithLiveDJ pdo'd --- .../application/models/ShowInstance.php | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index c19d8c3b7..03a4d60a2 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -36,17 +36,17 @@ class Application_Model_ShowInstance public function deleteRebroadcasts() { - $con = Propel::getConnection(); - $timestamp = gmdate("Y-m-d H:i:s"); $instance_id = $this->getShowInstanceId(); - - $sql = "DELETE FROM cc_show_instances" - ." WHERE starts > TIMESTAMP '$timestamp'" - ." AND instance_id = $instance_id" - ." AND rebroadcast = 1"; - - $con->exec($sql); + $sql = << :timestamp::TIMESTAMP +AND instance_id = :instanceId +AND rebroadcast = 1; +SQL; + Application_Common_Database::prepareAndExecute( $sql, array( + ':instanceId' => $instance_id, + ':timestamp' => $timestamp), 'execute'); } /* This function is weird. It should return a boolean, but instead returns @@ -821,16 +821,19 @@ SQL; // this returns end timestamp of all shows that are in the range and has live DJ set up public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime) { - global $CC_CONFIG; - $con = Propel::getConnection(); - - $sql = "SELECT ends - FROM cc_show_instances as si - JOIN cc_show as sh ON si.show_id = sh.id - WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth) - ORDER BY si.ends"; - - return $con->query($sql)->fetchAll(); + $sql = << :startTime::TIMESTAMP + AND si.ends < :endTime::TIMESTAMP + AND (sh.live_stream_using_airtime_auth + OR live_stream_using_custom_auth) +ORDER BY si.ends"; +SQL; + return Application_Common_Database::prepareAndExecute( $sql, array( + ':startTime' => $p_startTime, + ':endTime' => $p_endTime), 'all'); } public function isRepeating() From a0b3742758e065e2e697c0ac33ba2dae5c27145e Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:49:56 -0400 Subject: [PATCH 17/23] cc-4347: resizeShow pdo'd --- .../application/models/ShowInstance.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 03a4d60a2..825516ea6 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -324,11 +324,6 @@ SQL; Application_Model_RabbitMq::PushSchedule(); } - /* - * FUNCTION SHOULD NOT BE CALLED - * - we are removing ability to resize just a single show instance - * -please use the resize method on the Show.php class. - */ public function resizeShow($deltaDay, $deltaMin) { $con = Propel::getConnection(); @@ -372,9 +367,17 @@ SQL; //must update length of all rebroadcast instances. if ($this->isRecorded()) { - $sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') - WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}"; - $con->exec($sql); + $sql = << "$deltaDay days", + ':interval' => "$hours:$mins", + ':instanceId' => $this->_instanceId ), 'execute'); + } $this->setShowEnd($new_ends); From 8340db3ce91d326a563506627cbdf8144274b67d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:53:22 -0400 Subject: [PATCH 18/23] Added error handing todo --- airtime_mvc/application/models/ShowInstance.php | 1 + 1 file changed, 1 insertion(+) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 825516ea6..c4aa49611 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -360,6 +360,7 @@ SQL; $overlap = Application_Model_Show::getShows($utcStartDateTime, $utcEndDateTime); if (count($overlap) > 0) { + // TODO : fix ghetto error handling -- RG return "Should not overlap shows"; } } From 567a8a2635a77e7fc1244946fc761f7b0545a179 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 12:04:33 -0400 Subject: [PATCH 19/23] cc-4347: Fixed typo --- airtime_mvc/application/models/ShowInstance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index c4aa49611..a53bb3a8a 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -833,7 +833,7 @@ WHERE si.ends > :startTime::TIMESTAMP AND si.ends < :endTime::TIMESTAMP AND (sh.live_stream_using_airtime_auth OR live_stream_using_custom_auth) -ORDER BY si.ends"; +ORDER BY si.ends SQL; return Application_Common_Database::prepareAndExecute( $sql, array( ':startTime' => $p_startTime, From ac8610ca06450b3dd559a6b1d854690c30d8b03c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 10 Sep 2012 12:18:19 -0400 Subject: [PATCH 20/23] CC-4385: Problem with mono streams for stream rebroadcasting -fixed --- airtime_mvc/application/models/Webstream.php | 42 ++++++++++++------- .../pypo/liquidsoap_scripts/ls_lib.liq | 2 +- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php index 22d51a3e8..b1d4b2b77 100644 --- a/airtime_mvc/application/models/Webstream.php +++ b/airtime_mvc/application/models/Webstream.php @@ -178,10 +178,9 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable if (is_null($mime)) { throw new Exception("No MIME type found for webstream."); } - //TODO: return url $mediaUrl = self::getMediaUrl($url, $mime, $content_length_found); - if (preg_match("/(x-mpegurl)|(xspf\+xml)/", $mime)) { + if (preg_match("/(x-mpegurl)|(xspf\+xml)|(pls\+xml)/", $mime)) { list($mime, $content_length_found) = self::discoverStreamMime($mediaUrl); } } catch (Exception $e) { @@ -222,7 +221,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable } - private static function getXspfUrl($url) + private static function getUrlData($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); @@ -233,10 +232,17 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable //TODO: What if invalid url? $content = curl_exec($ch); - Logging::info($content); + Logging::debug($content); // close cURL resource, and free up system resources curl_close($ch); + + return $content; + } + + private static function getXspfUrl($url) + { + $content = self::getUrlData($url); $dom = new DOMDocument; //TODO: What if invalid xml? @@ -252,19 +258,23 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable throw new Exception("Could not parse XSPF playlist"); } + + private static function getPlsUrl($url) + { + $content = self::getUrlData($url); + + $ini = parse_ini_string($content, true); + + if ($ini !== false && isset($ini["playlist"]) && isset($ini["playlist"]["File1"])) { + return $ini["playlist"]["File1"]; + } + + throw new Exception("Could not parse PLS playlist"); + } private static function getM3uUrl($url) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - - // grab URL and pass it to the browser - //TODO: What if invalid url? - $content = curl_exec($ch); - Logging::info($content); - curl_close($ch); + $content = self::getUrlData($url); //split into lines: $delim = "\n"; @@ -288,6 +298,8 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable $media_url = self::getM3uUrl($url); } elseif (preg_match("/xspf\+xml/", $mime)) { $media_url = self::getXspfUrl($url); + } elseif (preg_match("/pls\+xml/", $mime)) { + $media_url = self::getPlsUrl($url); } elseif (preg_match("/(mpeg|ogg)/", $mime)) { if ($content_length_found) { throw new Exception("Invalid webstream - This appears to be a file download."); @@ -314,8 +326,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable } if (preg_match("/^content-length:/i", $h)) { $content_length_found = true; - //if content-length appears, this is not a web stream!!!! - //Aborting the save process. } } diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index 328ea21ab..085d03661 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -406,7 +406,7 @@ end # Function to create a playlist source and output it. def create_dynamic_source(uri) = # The playlist source - s = input.http(buffer=2., max=12., uri) + s = audio_to_stereo(input.http(buffer=2., max=12., uri)) # The output active_dyn_out = dyn_out(s) From 4d3c624607836ea4206aa52daad1f5b67b90c177 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 10 Sep 2012 12:35:32 -0400 Subject: [PATCH 21/23] CC-4380: Show ReplayGain value in the Library page - temp commit --- airtime_mvc/application/models/StoredFile.php | 2 +- .../models/airtime/map/CcFilesTableMap.php | 2 +- .../models/airtime/om/BaseCcFilesQuery.php | 23 +++++++++++++------ airtime_mvc/build/schema.xml | 2 +- airtime_mvc/build/sql/schema.sql | 4 ++-- .../public/js/airtime/library/library.js | 6 +++-- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 312208af8..53ded3e94 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -652,7 +652,7 @@ class Application_Model_StoredFile $displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url", "bit_rate", "sample_rate", "isrc_number", "encoded_by", "label", "copyright", "mime", - "language", "filepath","owner","conductor" + "language", "filepath", "owner", "conductor", "replay_gain" ); //Logging::info($datatables); diff --git a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php index 9c00c0b68..008c63007 100644 --- a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php @@ -100,7 +100,7 @@ class CcFilesTableMap extends TableMap { $this->addColumn('SOUNDCLOUD_ERROR_MSG', 'DbSoundcloudErrorMsg', 'VARCHAR', false, 512, null); $this->addColumn('SOUNDCLOUD_LINK_TO_FILE', 'DbSoundcloudLinkToFile', 'VARCHAR', false, 4096, null); $this->addColumn('SOUNDCLOUD_UPLOAD_TIME', 'DbSoundCloundUploadTime', 'TIMESTAMP', false, 6, null); - $this->addColumn('REPLAY_GAIN', 'DbReplayGain', 'VARCHAR', false, 16, null); + $this->addColumn('REPLAY_GAIN', 'DbReplayGain', 'NUMERIC', false, null, null); $this->addForeignKey('OWNER_ID', 'DbOwnerId', 'INTEGER', 'cc_subjs', 'ID', false, null, null); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php index 793bab857..0599719ac 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php @@ -1892,20 +1892,29 @@ abstract class BaseCcFilesQuery extends ModelCriteria /** * Filter the query on the replay_gain column * - * @param string $dbReplayGain The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @param string|array $dbReplayGain The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return CcFilesQuery The current query, for fluid interface */ public function filterByDbReplayGain($dbReplayGain = null, $comparison = null) { - if (null === $comparison) { - if (is_array($dbReplayGain)) { + if (is_array($dbReplayGain)) { + $useMinMax = false; + if (isset($dbReplayGain['min'])) { + $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbReplayGain['max'])) { + $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbReplayGain)) { - $dbReplayGain = str_replace('*', '%', $dbReplayGain); - $comparison = Criteria::LIKE; } } return $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain, $comparison); diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml index b03e14011..b9899cca8 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -74,7 +74,7 @@ - + diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql index 4fd4c1c45..cc47701c6 100644 --- a/airtime_mvc/build/sql/schema.sql +++ b/airtime_mvc/build/sql/schema.sql @@ -92,7 +92,7 @@ CREATE TABLE "cc_files" "soundcloud_error_msg" VARCHAR(512), "soundcloud_link_to_file" VARCHAR(4096), "soundcloud_upload_time" TIMESTAMP(6), - "replay_gain" VARCHAR(16), + "replay_gain" NUMERIC, "owner_id" INTEGER, PRIMARY KEY ("id") ); @@ -633,7 +633,7 @@ CREATE TABLE "cc_webstream" "id" serial NOT NULL, "name" VARCHAR(255) NOT NULL, "description" VARCHAR(255) NOT NULL, - "url" VARCHAR(255) NOT NULL, + "url" VARCHAR(512) NOT NULL, "length" interval default '00:00:00' NOT NULL, "creator_id" INTEGER NOT NULL, "mtime" TIMESTAMP(6) NOT NULL, diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index b648c6acc..ba7c0f574 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -36,7 +36,8 @@ var AIRTIME = (function(AIRTIME) { "track_title" : "s", "track_num" : "n", "year" : "n", - "owner" : "s" + "owner" : "s", + "replay_gain" : "n" }; if (AIRTIME.library === undefined) { @@ -414,7 +415,8 @@ var AIRTIME = (function(AIRTIME) { /* Mime */ { "sTitle" : "Mime" , "mDataProp" : "mime" , "bVisible" : false , "sClass" : "library_mime" , "sWidth" : "80px" } , /* Language */ { "sTitle" : "Language" , "mDataProp" : "language" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" } , /* Owner */ { "sTitle" : "Owner" , "mDataProp" : "owner" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" } , - /* Conductor */ { "sTitle" : "Conductor" , "mDataProp" : "conductor" , "bVisible" : false , "sClass" : "library_conductor" , "sWidth" : "125px" } + /* Conductor */ { "sTitle" : "Conductor" , "mDataProp" : "conductor" , "bVisible" : false , "sClass" : "library_conductor" , "sWidth" : "125px" }, + /* Replay Gain */ { "sTitle" : "Replay Gain" , "mDataProp" : "replay_gain" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" } ], "bProcessing": true, From 8d7a3a20425add875c697a6a65b0c51d0f21450d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 12:46:41 -0400 Subject: [PATCH 22/23] removed unused code --- python_apps/media-monitor2/media/monitor/manager.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/manager.py b/python_apps/media-monitor2/media/monitor/manager.py index fcceb153f..53599f3cb 100644 --- a/python_apps/media-monitor2/media/monitor/manager.py +++ b/python_apps/media-monitor2/media/monitor/manager.py @@ -28,8 +28,6 @@ class Manager(Loggable): include adding watched,store, organize directories, etc. Basically composes over WatchManager from pyinotify """ - global_inst = None - all_signals = set(['add_watch', 'remove_watch']) def __init__(self): self.wm = pyinotify.WatchManager() # These two instance variables are assumed to be constant @@ -66,7 +64,6 @@ class Manager(Loggable): # The following set isn't really necessary anymore. Should be # removed... self.watched_directories = set([]) - Manager.global_inst = self # This is the only event that we are unable to process "normally". I.e. # through dedicated handler objects. Because we must have access to a From e85a83d04551f36a48bbc22aadd64612c6c9b517 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 14:14:44 -0400 Subject: [PATCH 23/23] Fixed pdo --- airtime_mvc/application/models/ShowInstance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index a53bb3a8a..e6a3dcc58 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -816,7 +816,7 @@ SQL; $sql = << $day ), 'column' );