From 68c401b2964c686a1a955191bdbdbc2e6b379bf7 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 13 Aug 2012 11:04:21 -0400 Subject: [PATCH 01/62] airtime-check-system not using user define port in all cases --- utils/airtime-check-system.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 22ff7362c..fa244f3b3 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -17,7 +17,7 @@ if (substr($sapi_type, 0, 3) == 'cli') { $status = AirtimeCheck::GetStatus($baseUrl, $base_port, $apiKey); - AirtimeCheck::PrintStatus($baseUrl, $status); + AirtimeCheck::PrintStatus($baseUrl, $base_port, $status); } class AirtimeCheck { @@ -92,8 +92,9 @@ class AirtimeCheck { return $os_string." ".$machine; } - public static function GetServerType($p_baseUrl){ - $headerInfo = get_headers("http://$p_baseUrl",1); + public static function GetServerType($p_baseUrl, $p_basePort) + { + $headerInfo = get_headers("http://$p_baseUrl:$p_basePort",1); if (!isset($headerInfo['Server'][0])) return self::UNKNOWN; @@ -120,7 +121,7 @@ class AirtimeCheck { return $data; } - public static function PrintStatus($p_baseUrl, $p_status){ + public static function PrintStatus($p_baseUrl, $p_basePort, $p_status){ if ($p_status === false){ self::output_status("AIRTIME_SERVER_RESPONDING", "FAILED"); @@ -150,7 +151,7 @@ class AirtimeCheck { } self::output_status("OS", self::CheckOsTypeVersion()); self::output_status("CPU", self::GetCpuInfo()); - self::output_status("WEB_SERVER", self::GetServerType($p_baseUrl)); + self::output_status("WEB_SERVER", self::GetServerType($p_baseUrl, $p_basePort)); if (isset($data->services)) { $services = $data->services; From 831a1b192315ef7a957849cd4a03eab702a8c7ed Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 16 Aug 2012 23:49:37 -0400 Subject: [PATCH 02/62] CC-4242: MP3 streams have the artist name duplicated -fixed --- python_apps/pypo/liquidsoap_scripts/ls_lib.liq | 6 +++--- python_apps/pypo/liquidsoap_scripts/ls_script.liq | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index 83ab39322..78854f07d 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -7,11 +7,11 @@ end def append_title(m) = log("Using stream_format #{!stream_metadata_type}") if !stream_metadata_type == 1 then - [("artist","#{!show_name} - #{m['artist']}")] + [("title", "#{!show_name} - #{m['artist']}")] elsif !stream_metadata_type == 2 then - [("artist",!station_name), ("title", !show_name)] + [("title", "#{!station_name} - #{!show_name}")] else - [] + [("title", "#{m['artist']} - #{m['title']}")] end end diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 482a60a5e..dabd164a7 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -29,7 +29,7 @@ just_switched = ref false %include "ls_lib.liq" queue = on_metadata(notify, queue) -queue = map_metadata(append_title, queue) +queue = map_metadata(update=false, append_title, queue) # the crossfade function controls fade in/out queue = crossfade(queue) ignore(output.dummy(queue, fallible=true)) From 93d21b510c99a4c5433d8f0e34877dded2e48f2b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 20 Aug 2012 18:01:42 -0400 Subject: [PATCH 03/62] MM2: Fixed wrong use of split (misunderstanding of the maxsplit optional argument) --- python_apps/media-monitor2/media/monitor/eventcontractor.py | 4 +++- python_apps/media-monitor2/media/monitor/pure.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/eventcontractor.py b/python_apps/media-monitor2/media/monitor/eventcontractor.py index 77a5045fb..7e444b3ea 100644 --- a/python_apps/media-monitor2/media/monitor/eventcontractor.py +++ b/python_apps/media-monitor2/media/monitor/eventcontractor.py @@ -59,4 +59,6 @@ class EventContractor(Loggable): try: del self.store[evt.path] except Exception as e: self.unexpected_exception(e) - self.logger.info("Unregistering. Left: '%d'" % len(self.store.keys())) + # the next line is commented out because it clutters up logging real + # bad + #self.logger.info("Unregistering. Left: '%d'" % len(self.store.keys())) diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index 3f0b8bbe4..3b97ffe6f 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -247,7 +247,7 @@ def normalized_metadata(md, original_path): # Note: I don't know why I'm doing a unicode string comparison here # that part is copied from the original code if is_airtime_recorded(new_md): - hour,minute,second,name = md['MDATA_KEY_TITLE'].split("-",3) + hour,minute,second,name = new_md['MDATA_KEY_TITLE'].split("-",3) # We assume that MDATA_KEY_YEAR is always given for airtime recorded # shows new_md['MDATA_KEY_TITLE'] = u'%s-%s-%s:%s:%s' % \ @@ -280,7 +280,7 @@ def organized_path(old_path, root_path, orig_md): fname = u'%s-%s-%s.%s' % ( normal_md['MDATA_KEY_YEAR'], normal_md['MDATA_KEY_TITLE'], normal_md['MDATA_KEY_BITRATE'], ext ) - yyyy, mm, _ = normal_md['MDATA_KEY_YEAR'].split('-',3) + yyyy, mm, _ = normal_md['MDATA_KEY_YEAR'].split('-',2) path = os.path.join(root_path, yyyy, mm) filepath = os.path.join(path,fname) elif len(normal_md['MDATA_KEY_TRACKNUMBER']) == 0: From d517bf6e198855f44da614bbc3525a3a139dc98c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 20 Aug 2012 18:29:57 -0400 Subject: [PATCH 04/62] fix indentation and remove \r characters --- .../controllers/PlaylistController.php | 67 +++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index aa9dcd2f0..539e677bf 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -270,12 +270,11 @@ class PlaylistController extends Zend_Controller_Action $obj = null; $objInfo = $this->getObjInfo($type); - - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); try { - Logging::log("Currently active {$type} {$this->obj_sess->id}"); if (in_array($this->obj_sess->id, $ids)) { Logging::log("Deleting currently active {$type}"); @@ -290,11 +289,9 @@ class PlaylistController extends Zend_Controller_Action Application_Model_Block::deleteBlocks($ids, $userInfo->id); } $this->createFullResponse($obj); - } - catch (PlaylistNoPermissionException $e) { + } catch (PlaylistNoPermissionException $e) { $this->playlistNoPermission($type); - } - catch (PlaylistNotFoundException $e) { + } catch (PlaylistNotFoundException $e) { $this->playlistNotFound($type); } catch (Exception $e) { $this->playlistUnknownError($e); @@ -524,18 +521,18 @@ class PlaylistController extends Zend_Controller_Action $this->setPlaylistNameDescAction(); if ($params['type'] == 'block') { - $form = new Application_Form_SmartBlockCriteria(); + $form = new Application_Form_SmartBlockCriteria(); $form->startForm($params['obj_id']); - $bl = new Application_Model_Block($params['obj_id']); + $bl = new Application_Model_Block($params['obj_id']); if ($form->isValid($params)) { $bl->saveSmartBlockCriteria($params['data']); $result['html'] = $this->createFullResponse($bl, true); $result['result'] = 0; } else { - $this->view->obj = $bl; + $this->view->obj = $bl; $this->view->id = $bl->getId(); $this->view->form = $form; - $viewPath = 'playlist/smart-block.phtml'; + $viewPath = 'playlist/smart-block.phtml'; $result['html'] = $this->view->render($viewPath); $result['result'] = 1; } @@ -545,11 +542,11 @@ class PlaylistController extends Zend_Controller_Action die(json_encode($result)); } - public function smartBlockGenerateAction() - { - $request = $this->getRequest(); + public function smartBlockGenerateAction() + { + $request = $this->getRequest(); $params = $request->getPost(); - $form = new Application_Form_SmartBlockCriteria(); + $form = new Application_Form_SmartBlockCriteria(); $form->startForm($params['obj_id']); $bl = new Application_Model_Block($params['obj_id']); if ($form->isValid($params)) { @@ -564,35 +561,35 @@ class PlaylistController extends Zend_Controller_Action $this->playlistUnknownError($e); } }else{ - $this->view->obj = $bl; - $this->view->id = $bl->getId(); - $this->view->form = $form; - $viewPath = 'playlist/smart-block.phtml'; + $this->view->obj = $bl; + $this->view->id = $bl->getId(); + $this->view->form = $form; + $viewPath = 'playlist/smart-block.phtml'; $result['html'] = $this->view->render($viewPath); $result['result'] = 1; die(json_encode($result)); - } + } } public function smartBlockShuffleAction() { - $request = $this->getRequest(); + $request = $this->getRequest(); $params = $request->getPost(); $bl = new Application_Model_Block($params['obj_id']); $result = $bl->shuffleSmartBlock(); - - if ($result['result'] == 0) { - try { - die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); - } - catch (PlaylistNotFoundException $e) { - $this->playlistNotFound('block'); - } - catch (Exception $e) { - $this->playlistUnknownError($e); - } - }else{ - die(json_encode($result)); + + if ($result['result'] == 0) { + try { + die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); + } + catch (PlaylistNotFoundException $e) { + $this->playlistNotFound('block'); + } + catch (Exception $e) { + $this->playlistUnknownError($e); + } + }else{ + die(json_encode($result)); } } @@ -610,7 +607,7 @@ class PlaylistController extends Zend_Controller_Action } public function getBlockInfoAction(){ - $request = $this->getRequest(); + $request = $this->getRequest(); $params = $request->getPost(); $bl = new Application_Model_Block($params['id']); if ($bl->isStatic()) { From 3230f1423182f48c7d141916f0afd71b913a4cb0 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 20 Aug 2012 18:35:10 -0400 Subject: [PATCH 05/62] CC-1665: Scheduled stream rebroadcasting and recording -Fixed delete button on right side of library screen not working --- .../controllers/WebstreamController.php | 10 ++++++++ .../views/scripts/webstream/webstream.phtml | 6 +++-- airtime_mvc/public/js/airtime/library/spl.js | 23 ++++++++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index 73ad7fc59..bf67e13bd 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -8,6 +8,7 @@ class WebstreamController extends Zend_Controller_Action $ajaxContext->addActionContext('new', 'json') ->addActionContext('save', 'json') ->addActionContext('edit', 'json') + ->addActionContext('delete', 'json') ->initContext(); //TODO //$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); @@ -46,6 +47,15 @@ class WebstreamController extends Zend_Controller_Action $this->view->html = $this->view->render('webstream/webstream.phtml'); } + public function deleteAction() + { + $request = $this->getRequest(); + $id = $request->getParam("ids"); + + $webstream = CcWebstreamQuery::create()->findPK($id)->delete(); + + } + public function saveAction() { $request = $this->getRequest(); diff --git a/airtime_mvc/application/views/scripts/webstream/webstream.phtml b/airtime_mvc/application/views/scripts/webstream/webstream.phtml index d3660bfc4..939cfffde 100644 --- a/airtime_mvc/application/views/scripts/webstream/webstream.phtml +++ b/airtime_mvc/application/views/scripts/webstream/webstream.phtml @@ -4,9 +4,11 @@ ws)) : ?> - - + + ws->getLastModified('U'); ?>"> + +

diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 92bf939c9..5a820bb32 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -6,7 +6,7 @@ var AIRTIME = (function(AIRTIME){ if (AIRTIME.playlist === undefined) { AIRTIME.playlist = {}; - } + } var mod = AIRTIME.playlist, viewport, @@ -802,6 +802,23 @@ var AIRTIME = (function(AIRTIME){ redrawLib(); }); }; + + mod.fnWsDelete = function(wsid) { + var url, id, lastMod; + + stopAudioPreview(); + id = (wsid === undefined) ? getId() : wsid; + lastMod = getModified(); + type = $('#obj_type').val(); + url = '/Webstream/delete'; + + $.post(url, + {format: "json", ids: id, modified: lastMod, type: type}, + function(json){ + openPlaylist(json); + redrawLib(); + }); + }; mod.disableUI = function() { @@ -903,6 +920,10 @@ var AIRTIME = (function(AIRTIME){ $pl.delegate("#spl_delete", {"click": function(ev){ AIRTIME.playlist.fnDelete(); }}); + + $pl.delegate("#ws_delete", {"click": function(ev){ + AIRTIME.playlist.fnWsDelete(); + }}); setPlaylistEntryEvents(); setCueEvents(); From cba717dc4b9bd015daaea228f2e6ea4d33a54220 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 10:33:36 -0400 Subject: [PATCH 06/62] CC-1665: Scheduled stream rebroadcasting and recording -Fixed regressions introduced by changing HTML element id --- airtime_mvc/public/js/airtime/library/spl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 577987284..7074b07b7 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -568,7 +568,7 @@ var AIRTIME = (function(AIRTIME){ //stream url //default_length //playlist name - var id = $pl.find("#ws_id").attr("value"); + var id = $pl.find("#obj_id").attr("value"); var description = $pl.find("#description").val(); var streamurl = $pl.find("#streamurl-element input").val(); var length = $pl.find("#streamlength-element input").val(); @@ -596,7 +596,7 @@ var AIRTIME = (function(AIRTIME){ $status.show(); setTimeout(function(){$status.fadeOut("slow", function(){$status.empty()})}, 5000); - var $ws_id = $("#ws_id"); + var $ws_id = $("#obj_id"); $ws_id.attr("value", json.streamId); var $ws_id = $("#ws_delete"); From 4cd5dbb92654889699253434174c45f2f3fa9b5d Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 21 Aug 2012 10:42:10 -0400 Subject: [PATCH 07/62] CC-4205: Smart Playlist Builder: Change text on button mouseovers -changed save button text --- airtime_mvc/application/views/scripts/playlist/playlist.phtml | 2 +- .../application/views/scripts/playlist/smart-block.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/views/scripts/playlist/playlist.phtml b/airtime_mvc/application/views/scripts/playlist/playlist.phtml index 70ce2faea..8ca2af991 100644 --- a/airtime_mvc/application/views/scripts/playlist/playlist.phtml +++ b/airtime_mvc/application/views/scripts/playlist/playlist.phtml @@ -13,7 +13,7 @@ if (isset($this->obj)) { obj)) : ?> - + diff --git a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml index d3874d5fd..9b43655f6 100644 --- a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml +++ b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml @@ -10,7 +10,7 @@ if (isset($this->obj)) { "> Playlist crossfade - + obj)) : ?> From 025656be1cec94db54d501cffedf0f7752a29e1d Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 21 Aug 2012 10:46:25 -0400 Subject: [PATCH 08/62] CC-4205: Smart Playlist Builder: Change text on button mouseovers -changed generate success msg --- airtime_mvc/application/forms/SmartBlockCriteria.php | 2 +- airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/forms/SmartBlockCriteria.php b/airtime_mvc/application/forms/SmartBlockCriteria.php index f23885414..0e68f957a 100644 --- a/airtime_mvc/application/forms/SmartBlockCriteria.php +++ b/airtime_mvc/application/forms/SmartBlockCriteria.php @@ -240,7 +240,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $generate = new Zend_Form_Element_Button('generate_button'); $generate->setAttrib('class', 'ui-button ui-state-default sp-button'); - $generate->setAttrib('title', 'Generate playlist content'); + $generate->setAttrib('title', 'Generate playlist content and save criteria'); $generate->setIgnore(true); $generate->setLabel('Generate'); $generate->setDecorators(array('viewHelper')); diff --git a/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js b/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js index 00b55e7df..05c0422ce 100644 --- a/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js +++ b/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js @@ -458,7 +458,7 @@ function callback(data, type) { if (type == 'shuffle') { form.find('.success').text('Smart block shuffled'); } else if (type == 'generate') { - form.find('.success').text('Smart block generated and saved'); + form.find('.success').text('Smart block generated and criteria saved'); //redraw library table so the length gets updated dt.fnStandingRedraw(); } From bb1e67a83c34eed3ebe57ccaef7a415c85beac3a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 10:46:48 -0400 Subject: [PATCH 09/62] small refactoring of to os.path.join instead of manual path concatenation. --- python_apps/pypo/recorder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index 00d51c010..de48afd1c 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -73,16 +73,18 @@ class ShowRecorder(Thread): else: filetype = "ogg"; - filepath = "%s%s.%s" % (config["base_recorded_files"], filename, filetype) + joined_path = os.path.join(config["base_recorded_files"], filename) + filepath = "%s.%s" % (joined_path, filetype) br = config["record_bitrate"] sr = config["record_samplerate"] - c = config["record_channels"] + c = config["record_channels"] ss = config["record_sample_size"] #-f:16,2,44100 #-b:256 - command = "ecasound -f:%s,%s,%s -i alsa -o %s,%s000 -t:%s" % (ss, c, sr, filepath, br, length) + command = "ecasound -f:%s,%s,%s -i alsa -o %s,%s000 -t:%s" % \ + (ss, c, sr, filepath, br, length) args = command.split(" ") self.logger.info("starting record") From 179aa3d7390d1859b2c5d2a8b8ea8473e055324d Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 10:50:18 -0400 Subject: [PATCH 10/62] CC-1665: Scheduled stream rebroadcasting and recording -Show meaningful page after webstream is deleted --- airtime_mvc/application/controllers/WebstreamController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index bf67e13bd..c195b23c7 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -54,6 +54,10 @@ class WebstreamController extends Zend_Controller_Action $webstream = CcWebstreamQuery::create()->findPK($id)->delete(); + $this->view->ws = null; + $this->view->action = "delete"; + $this->view->html = $this->view->render('webstream/webstream.phtml'); + } public function saveAction() From 47852bce2a69a3bb93a1aff93aabbf31c69176b8 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 10:50:24 -0400 Subject: [PATCH 11/62] indentation fixes --- .../controllers/PlaylistController.php | 74 +++++++++---------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 91ad684d7..b60bcdaaf 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -106,14 +106,13 @@ class PlaylistController extends Zend_Controller_Action } else { $this->view->html = $this->view->render($viewPath); } - }else{ + } else { $this->view->obj = $obj; $this->view->id = $obj->getId(); $this->view->html = $this->view->render($viewPath); unset($this->view->obj); } - } - else { + } else { $this->view->html = $this->view->render($viewPath); } } @@ -138,7 +137,8 @@ class PlaylistController extends Zend_Controller_Action $this->createFullResponse(null); } - private function playlistNoPermission($p_type){ + private function playlistNoPermission($p_type) + { $this->view->error = "You don't have permission to delete selected {$p_type}(s)."; } @@ -151,12 +151,14 @@ class PlaylistController extends Zend_Controller_Action Logging::log("{$e->getMessage()}"); } - private function wrongTypeToBlock($obj) { + private function wrongTypeToBlock($obj) + { $this->view->error = "You can only add tracks to smart block."; $this->createFullResponse($obj); } - private function wrongTypeToPlaylist($obj) { + private function wrongTypeToPlaylist($obj) + { $this->view->error = "You can only add tracks and smart blocks to playlists."; $this->createFullResponse($obj); } @@ -168,27 +170,27 @@ class PlaylistController extends Zend_Controller_Action $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); - $this->view->headScript()->appendFile($baseUrl.'/js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_playlistbuilder.js'),'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_playlistbuilder.js'), 'text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/playlist/smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/playlist/smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']); try { @@ -199,9 +201,9 @@ class PlaylistController extends Zend_Controller_Action $user = new Application_Model_User($userInfo->id); $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); - if($isAdminOrPM || $obj->getCreatorId() == $userInfo->id){ + if ($isAdminOrPM || $obj->getCreatorId() == $userInfo->id) { $this->view->obj = $obj; - if($this->obj_sess->type == "block"){ + if ($this->obj_sess->type == "block") { $form = new Application_Form_SmartBlockCriteria(); $form->startForm($this->obj_sess->id); $this->view->form = $form; @@ -283,6 +285,7 @@ class PlaylistController extends Zend_Controller_Action Logging::log("Not deleting currently active {$type}"); $obj = new $objInfo['className']($this->obj_sess->id); } + if (strcmp($objInfo['className'], 'Application_Model_Playlist')==0) { Application_Model_Playlist::deletePlaylists($ids, $userInfo->id); } else { @@ -310,7 +313,7 @@ class PlaylistController extends Zend_Controller_Action try { $obj = $this->getPlaylist($obj_type); if ($obj_type == 'playlist') { - foreach($ids as $id) { + foreach ($ids as $id) { if (is_array($id) && isset($id[1])) { if ($id[1] == 'playlist') { throw new WrongTypeToPlaylistException; @@ -321,7 +324,7 @@ class PlaylistController extends Zend_Controller_Action } else if ($obj->isStatic()) { // if the dest is a block object //check if any items are playlists - foreach($ids as $id) { + foreach ($ids as $id) { if (is_array($id) && isset($id[1])) { if ($id[1] != 'audioclip') { throw new WrongTypeToBlockException; @@ -333,11 +336,9 @@ class PlaylistController extends Zend_Controller_Action throw new BlockDynamicException; } $this->createUpdateResponse($obj); - } - catch (PlaylistOutDatedException $e) { + } catch (PlaylistOutDatedException $e) { $this->playlistOutdated($e); - } - catch (PlaylistNotFoundException $e) { + } catch (PlaylistNotFoundException $e) { $this->playlistNotFound($obj_type); } catch (WrongTypeToBlockException $e) { @@ -553,14 +554,12 @@ class PlaylistController extends Zend_Controller_Action $result = $bl->generateSmartBlock($params['data']); try { die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); - } - catch (PlaylistNotFoundException $e) { + } catch (PlaylistNotFoundException $e) { $this->playlistNotFound('block'); - } - catch (Exception $e) { + } catch (Exception $e) { $this->playlistUnknownError($e); } - }else{ + } else { $this->view->obj = $bl; $this->view->id = $bl->getId(); $this->view->form = $form; @@ -581,14 +580,10 @@ class PlaylistController extends Zend_Controller_Action if ($result['result'] == 0) { try { die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); - } - catch (PlaylistNotFoundException $e) { + } catch (PlaylistNotFoundException $e) { $this->playlistNotFound('block'); } - catch (Exception $e) { - $this->playlistUnknownError($e); - } - }else{ + } else { die(json_encode($result)); } } @@ -606,7 +601,8 @@ class PlaylistController extends Zend_Controller_Action return $info; } - public function getBlockInfoAction(){ + public function getBlockInfoAction() + { $request = $this->getRequest(); $params = $request->getPost(); $bl = new Application_Model_Block($params['id']); From 51ebae3de92a859860fa2052f567b5881abf6541 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 11:12:33 -0400 Subject: [PATCH 12/62] Make sure we are using the Library controller for the Library page --- .../application/configs/navigation.php | 2 +- .../controllers/LibraryController.php | 61 ++++++++++++++++++- .../controllers/PlaylistController.php | 23 ++----- airtime_mvc/application/models/Playlist.php | 13 ++++ .../scripts/{playlist => library}/index.phtml | 0 5 files changed, 79 insertions(+), 20 deletions(-) rename airtime_mvc/application/views/scripts/{playlist => library}/index.phtml (100%) diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index 4d63196fa..5874aa8e2 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -25,7 +25,7 @@ $pages = array( array( 'label' => 'Library', 'module' => 'default', - 'controller' => 'Playlist', + 'controller' => 'Library', 'action' => 'index', 'resource' => 'playlist' ), diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 79f95ba4f..3ba5738bd 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -27,6 +27,65 @@ class LibraryController extends Zend_Controller_Action $this->search_sess = new Zend_Session_Namespace("search"); } + public function indexAction() + { + global $CC_CONFIG; + + $request = $this->getRequest(); + $baseUrl = $request->getBaseUrl(); + + $this->view->headScript()->appendFile($baseUrl.'/js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_playlistbuilder.js'), 'text/javascript'); + + $this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']); + $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); + $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); + $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); + + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/playlist/smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']); + + try { + if (isset($this->obj_sess->id)) { + $objInfo = Application_Model_Playlist::getObjInfo($this->obj_sess->type); + $obj = new $objInfo['className']($this->obj_sess->id); + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); + + if ($isAdminOrPM || $obj->getCreatorId() == $userInfo->id) { + $this->view->obj = $obj; + if ($this->obj_sess->type == "block") { + $form = new Application_Form_SmartBlockCriteria(); + $form->startForm($this->obj_sess->id); + $this->view->form = $form; + } + } + + $formatter = new LengthFormatter($obj->getLength()); + $this->view->length = $formatter->format(); + $this->view->type = $this->obj_sess->type; + } + } catch (PlaylistNotFoundException $e) { + $this->playlistNotFound($this->obj_sess->type); + } catch (Exception $e) { + $this->playlistUnknownError($e); + } + } + + public function contextMenuAction() { $id = $this->_getParam('id'); @@ -270,7 +329,7 @@ class LibraryController extends Zend_Controller_Action Logging::log($data['MDATA_KEY_FILEPATH']); Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data); - $this->_redirect('Playlist'); + $this->_redirect('Library'); } } diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index b60bcdaaf..28ea6b5f6 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -39,7 +39,7 @@ class PlaylistController extends Zend_Controller_Action { $obj = null; - $objInfo = $this->getObjInfo($p_type); + $objInfo = Application_Model_Playlist::getObjInfo($p_type); if (isset($this->obj_sess->id)) { $obj = new $objInfo['className']($this->obj_sess->id); @@ -195,7 +195,7 @@ class PlaylistController extends Zend_Controller_Action try { if (isset($this->obj_sess->id)) { - $objInfo = $this->getObjInfo($this->obj_sess->type); + $objInfo = Application_Model_Playlist::getObjInfo($this->obj_sess->type); $obj = new $objInfo['className']($this->obj_sess->id); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -227,7 +227,7 @@ class PlaylistController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $type = $this->_getParam('type'); - $objInfo = $this->getObjInfo($type); + $objInfo = Application_Model_Playlist::getObjInfo($type); $name = 'Untitled Playlist'; if ($type == 'block') { @@ -246,7 +246,7 @@ class PlaylistController extends Zend_Controller_Action { $id = $this->_getParam('id', null); $type = $this->_getParam('type'); - $objInfo = $this->getObjInfo($type); + $objInfo = Application_Model_Playlist::getObjInfo($type); Logging::log("editing {$type} {$id}"); if (!is_null($id)) { @@ -271,7 +271,7 @@ class PlaylistController extends Zend_Controller_Action $obj = null; - $objInfo = $this->getObjInfo($type); + $objInfo = Application_Model_Playlist::getObjInfo($type); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -588,19 +588,6 @@ class PlaylistController extends Zend_Controller_Action } } - public function getObjInfo($p_type) - { - $info = array(); - - if (strcmp($p_type, 'playlist')==0) { - $info['className'] = 'Application_Model_Playlist'; - } else { - $info['className'] = 'Application_Model_Block'; - } - - return $info; - } - public function getBlockInfoAction() { $request = $this->getRequest(); diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 19023fc8d..29dcd03f8 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -899,6 +899,19 @@ SQL; CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete(); } + public static function getObjInfo($p_type) + { + $info = array(); + + if (strcmp($p_type, 'playlist')==0) { + $info['className'] = 'Application_Model_Playlist'; + } else { + $info['className'] = 'Application_Model_Block'; + } + + return $info; + } + } // class Playlist class PlaylistNotFoundException extends Exception {} diff --git a/airtime_mvc/application/views/scripts/playlist/index.phtml b/airtime_mvc/application/views/scripts/library/index.phtml similarity index 100% rename from airtime_mvc/application/views/scripts/playlist/index.phtml rename to airtime_mvc/application/views/scripts/library/index.phtml From 0ce4c1000be977fbf57cc06af0cfba3d100960ce Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 11:13:27 -0400 Subject: [PATCH 13/62] replace tabs with spaces -also remove \r characters --- .../application/configs/navigation.php | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index 5874aa8e2..724fa4c40 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -8,38 +8,38 @@ * the navigation container below. */ $pages = array( - array( + array( 'label' => 'Now Playing', 'module' => 'default', 'controller' => 'Showbuilder', 'action' => 'index', - 'resource' => 'showbuilder' - ), - array( - 'label' => 'Add Media', - 'module' => 'default', - 'controller' => 'Plupload', - 'action' => 'index', - 'resource' => 'plupload' - ), - array( - 'label' => 'Library', - 'module' => 'default', - 'controller' => 'Library', - 'action' => 'index', - 'resource' => 'playlist' - ), - array( + 'resource' => 'showbuilder' + ), + array( + 'label' => 'Add Media', + 'module' => 'default', + 'controller' => 'Plupload', + 'action' => 'index', + 'resource' => 'plupload' + ), + array( + 'label' => 'Library', + 'module' => 'default', + 'controller' => 'Library', + 'action' => 'index', + 'resource' => 'playlist' + ), + array( 'label' => 'Calendar', 'module' => 'default', 'controller' => 'Schedule', 'action' => 'index', - 'resource' => 'schedule' - ), + 'resource' => 'schedule' + ), array( 'label' => 'System', - 'uri' => '#', - 'resource' => 'preference', + 'uri' => '#', + 'resource' => 'preference', 'pages' => array( array( 'label' => 'Preferences', @@ -51,14 +51,14 @@ $pages = array( 'module' => 'default', 'controller' => 'user', 'action' => 'add-user', - 'resource' => 'user' + 'resource' => 'user' ), array( 'label' => 'Media Folders', 'module' => 'default', 'controller' => 'Preference', 'action' => 'directory-config', - 'id' => 'manage_folder' + 'id' => 'manage_folder' ), array( 'label' => 'Streams', @@ -77,28 +77,28 @@ $pages = array( 'module' => 'default', 'controller' => 'systemstatus', 'action' => 'index', - 'resource' => 'systemstatus' + 'resource' => 'systemstatus' ), - array( - 'label' => 'Playout History', - 'module' => 'default', - 'controller' => 'playouthistory', - 'action' => 'index', - 'resource' => 'playouthistory' - ) + array( + 'label' => 'Playout History', + 'module' => 'default', + 'controller' => 'playouthistory', + 'action' => 'index', + 'resource' => 'playouthistory' + ) ) ), - array( - 'label' => 'Help', - 'uri' => '#', - 'resource' => 'dashboard', + array( + 'label' => 'Help', + 'uri' => '#', + 'resource' => 'dashboard', 'pages' => array( array( 'label' => 'Getting Started', 'module' => 'default', 'controller' => 'dashboard', 'action' => 'help', - 'resource' => 'dashboard' + 'resource' => 'dashboard' ), array( 'label' => 'User Manual', @@ -110,10 +110,10 @@ $pages = array( 'module' => 'default', 'controller' => 'dashboard', 'action' => 'about', - 'resource' => 'dashboard' + 'resource' => 'dashboard' ) ) - ) + ) ); From 0c381d4692490d2ea3f5dbcaea5fdee4869514bb Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 21 Aug 2012 11:58:39 -0400 Subject: [PATCH 14/62] CC-4253: Smart Playlist: Please support filter tracks by date -fixed --- airtime_mvc/application/models/Block.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index fbd429d1e..00cdf1c04 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -1140,7 +1140,17 @@ EOT; $column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$spCriteria]); // if the column is timestamp, convert it into UTC if ($column->getType() == PropelColumnTypes::TIMESTAMP) { - $spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($criteria['value']); + /* Check if only a date was supplied and trim + * the time after it is converted to UTC time + */ + if (strlen($criteria['value']) <= 10) { + //extract date only from timestamp in db + $spCriteria = 'date('.$spCriteria.')'; + $spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($criteria['value']); + $spCriteriaValue = substr($spCriteriaValue, 0, 10); + } else { + $spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($criteria['value']); + } } else if($spCriteria == "bit_rate") { // multiply 1000 because we store only number value // e.g 192kps is stored as 192000 From 142eb6b66ed7b3ecb9c41a49e6352e20423fcd84 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 11:59:29 -0400 Subject: [PATCH 15/62] cc-4241: Updated tests to test for this bug automatically. --- python_apps/media-monitor2/tests/test_pure.py | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/python_apps/media-monitor2/tests/test_pure.py b/python_apps/media-monitor2/tests/test_pure.py index 611c42f60..5868b96bb 100644 --- a/python_apps/media-monitor2/tests/test_pure.py +++ b/python_apps/media-monitor2/tests/test_pure.py @@ -2,6 +2,7 @@ import unittest import os import media.monitor.pure as mmp +from media.monitor.metadata import Metadata class TestMMP(unittest.TestCase): def setUp(self): @@ -34,23 +35,28 @@ class TestMMP(unittest.TestCase): for k in def_keys: self.assertEqual( sd[k], 'DEF' ) def test_normalized_metadata(self): - normal = mmp.normalized_metadata(self.md1,"") - self.assertTrue(hasattr(normal['MDATA_KEY_CREATOR'],'startswith')) - self.assertTrue('MDATA_KEY_CREATOR' in normal) - self.assertTrue('MDATA_KEY_SOURCE' in normal) + # Recorded show test first + orig = Metadata.airtime_dict({ + 'date': [u'2012-08-21'], + 'tracknumber': [u'2'], + 'title': [u'11-29-00-record'], + 'artist': [u'Airtime Show Recorder'] + }) + orga = Metadata.airtime_dict({ + 'date': [u'2012-08-21'], + 'tracknumber': [u'2'], + 'artist': [u'Airtime Show Recorder'], + 'title': [u'record-2012-08-21-11:29:00'] + }) + orga['MDATA_KEY_FTYPE'] = u'audioclip' + old_path = "/home/rudi/recorded/2012-08-21-11:29:00.ogg" + normalized = mmp.normalized_metadata(orig, old_path) + self.assertEqual( orga, normalized ) - def test_organized_path(self): - o_path = '/home/rudi/throwaway/ACDC_-_Back_In_Black-sample-64kbps.ogg' - normal = mmp.normalized_metadata(self.md1,o_path) - og = mmp.organized_path(o_path, - '/home/rudi/throwaway/fucking_around/watch/', - normal) - real_path1 = \ - u'/home/rudi/throwaway/fucking_around/watch/unknown/unknown/ACDC_-_Back_In_Black-sample-64kbps-64kbps.ogg' - self.assertTrue( 'unknown' in og, True ) - self.assertEqual( og, real_path1 ) # TODO : fix this failure - # for recorded it should be something like this - # ./recorded/2012/07/2012-07-09-17-55-00-Untitled Show-256kbps.ogg + organized_base_name = "2012-08-21-11-29-00-record-256kbps.ogg" + base = "/srv/airtime/stor/" + organized_path = mmp.organized_path(old_path,base, normalized) + self.assertEqual(os.path.basename(organized_path), organized_base_name) def test_file_md5(self): p = os.path.realpath(__file__) From 167881c903c613b4ac786d5e700ffb79f7afe834 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 21 Aug 2012 12:01:48 -0400 Subject: [PATCH 16/62] CC-4253: Smart Playlist: Please support filter tracks by date -code refactor --- airtime_mvc/application/models/Block.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index 00cdf1c04..d5816fab5 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -1140,16 +1140,14 @@ EOT; $column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$spCriteria]); // if the column is timestamp, convert it into UTC if ($column->getType() == PropelColumnTypes::TIMESTAMP) { + $spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($criteria['value']); /* Check if only a date was supplied and trim * the time after it is converted to UTC time */ if (strlen($criteria['value']) <= 10) { //extract date only from timestamp in db $spCriteria = 'date('.$spCriteria.')'; - $spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($criteria['value']); $spCriteriaValue = substr($spCriteriaValue, 0, 10); - } else { - $spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($criteria['value']); } } else if($spCriteria == "bit_rate") { // multiply 1000 because we store only number value From 2a497bf941ef68ee9c7ee9c712d198b9f82e97fb Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 12:06:07 -0400 Subject: [PATCH 17/62] remove symlink, not actual binary --- python_apps/pypo/install/pypo-initialize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python_apps/pypo/install/pypo-initialize.py b/python_apps/pypo/install/pypo-initialize.py index 357aa49c6..01fe004bb 100644 --- a/python_apps/pypo/install/pypo-initialize.py +++ b/python_apps/pypo/install/pypo-initialize.py @@ -85,16 +85,16 @@ try: p = Popen("which liquidsoap", shell=True, stdout=PIPE) liq_path = p.communicate()[0].strip() + symlink_path = "/usr/bin/airtime-liquidsoap" if p.returncode == 0: try: - os.unlink(liq_path) + os.remove(symlink_path) except Exception: #liq_path DNE, which is OK. pass - - os.symlink(liq_path, "/usr/bin/airtime-liquidsoap") + os.symlink(liq_path, symlink_path) else: print " * Liquidsoap binary not found!" sys.exit(1) From 20cfd01f80a38acea6144d4c8e24e425507bfc5f Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 12:20:15 -0400 Subject: [PATCH 18/62] CC-1665: Scheduled stream rebroadcasting and recording -ls_script cleanup --- python_apps/pypo/liquidsoap_scripts/ls_script.liq | 4 ---- 1 file changed, 4 deletions(-) diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index c3bec6818..3696b0d83 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -27,7 +27,6 @@ stream_metadata_type = ref 0 default_dj_fade = ref 0. station_name = ref '' show_name = ref '' -#current_media_id = ref '' s1_connected = ref '' s2_connected = ref '' @@ -47,9 +46,6 @@ queue = map_metadata(update=false, append_title, queue) # the crossfade function controls fade in/out queue = crossfade(queue) -#make sure we are clearing all buffered data even when the source isn't being actively used -#output.dummy(queue, fallible=true) -#output.dummy(web_stream, fallible=true) stream_queue = switch(id="stream_queue_switch", track_sensitive=false, transitions=[transition, transition], [({!webstream_enabled},web_stream), ({true}, queue)]) From bbf5a8641511ca888b151114896d1cd20ada0f32 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 12:34:29 -0400 Subject: [PATCH 19/62] MM2: refactoring of metadata handling --- .../media-monitor2/media/monitor/metadata.py | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/metadata.py b/python_apps/media-monitor2/media/monitor/metadata.py index a8c982b9a..5f222c4b4 100644 --- a/python_apps/media-monitor2/media/monitor/metadata.py +++ b/python_apps/media-monitor2/media/monitor/metadata.py @@ -105,10 +105,38 @@ class Metadata(Loggable): # little bit messy. Some of the handling is in m.m.pure while the rest is # here. Also interface is not very consistent + @staticmethod + def airtime_dict(d): + """ + Converts mutagen dictionary 'd' into airtime dictionary + """ + temp_dict = {} + for m_key, m_val in d.iteritems(): + # TODO : some files have multiple fields for the same metadata. + # genre is one example. In that case mutagen will return a list + # of values + assign_val = m_val[0] if isinstance(m_val, list) else m_val + temp_dict[ m_key ] = assign_val + airtime_dictionary = {} + for muta_k, muta_v in temp_dict.iteritems(): + # We must check if we can actually translate the mutagen key into + # an airtime key before doing the conversion + if muta_k in mutagen2airtime: + airtime_key = mutagen2airtime[muta_k] + # Apply truncation in the case where airtime_key is in our + # truncation table + muta_v = \ + truncate_to_length(muta_v, truncate_table[airtime_key])\ + if airtime_key in truncate_table else muta_v + airtime_dictionary[ airtime_key ] = muta_v + return airtime_dictionary + @staticmethod def write_unsafe(path,md): """ - Writes 'md' metadata into 'path' through mutagen + Writes 'md' metadata into 'path' through mutagen. Converts all + dictionary values to strings because mutagen will not write anything + else """ if not os.path.exists(path): raise BadSongFile(path) song_file = mutagen.File(path, easy=True) @@ -128,37 +156,13 @@ class Metadata(Loggable): self.path = fpath # TODO : Simplify the way all of these rules are handled right not it's # extremely unclear and needs to be refactored. - metadata = {} - # Load only the metadata avilable in mutagen into metdata - for k,v in full_mutagen.iteritems(): - # Special handling of attributes here - if isinstance(v, list): - # TODO : some files have multiple fields for the same metadata. - # genre is one example. In that case mutagen will return a list - # of values - metadata[k] = v[0] - #if len(v) == 1: metadata[k] = v[0] - #else: raise Exception("Unknown mutagen %s:%s" % (k,str(v))) - else: metadata[k] = v - self.__metadata = {} - # Start populating a dictionary of airtime metadata in __metadata - for muta_k, muta_v in metadata.iteritems(): - # We must check if we can actually translate the mutagen key into - # an airtime key before doing the conversion - if muta_k in mutagen2airtime: - airtime_key = mutagen2airtime[muta_k] - # Apply truncation in the case where airtime_key is in our - # truncation table - muta_v = \ - truncate_to_length(muta_v, truncate_table[airtime_key])\ - if airtime_key in truncate_table else muta_v - self.__metadata[ airtime_key ] = muta_v + self.__metadata = Metadata.airtime_dict(full_mutagen) # Now we extra the special values that are calculated from the mutagen # object itself: for special_key,f in airtime_special.iteritems(): new_val = f(full_mutagen) if new_val is not None: - self.__metadata[special_key] = f(full_mutagen) + self.__metadata[special_key] = new_val # Finally, we "normalize" all the metadata here: self.__metadata = mmp.normalized_metadata(self.__metadata, fpath) # Now we must load the md5: From 01060f560c791c505452e7e5c271003aff2a7326 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 12:49:57 -0400 Subject: [PATCH 20/62] cc-4241: corrected unit test. --- python_apps/media-monitor2/tests/test_pure.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python_apps/media-monitor2/tests/test_pure.py b/python_apps/media-monitor2/tests/test_pure.py index 5868b96bb..e822f3cf5 100644 --- a/python_apps/media-monitor2/tests/test_pure.py +++ b/python_apps/media-monitor2/tests/test_pure.py @@ -48,9 +48,13 @@ class TestMMP(unittest.TestCase): 'artist': [u'Airtime Show Recorder'], 'title': [u'record-2012-08-21-11:29:00'] }) - orga['MDATA_KEY_FTYPE'] = u'audioclip' + orga['MDATA_KEY_FTYPE'] = u'audioclip' + orig['MDATA_KEY_BITRATE'] = u'256000' + orga['MDATA_KEY_BITRATE'] = u'256kbps' + old_path = "/home/rudi/recorded/2012-08-21-11:29:00.ogg" normalized = mmp.normalized_metadata(orig, old_path) + print(normalized) self.assertEqual( orga, normalized ) organized_base_name = "2012-08-21-11-29-00-record-256kbps.ogg" From 8dc4bcb7d331c9bf77d2abadce84b55b76f74d1c Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 12:50:29 -0400 Subject: [PATCH 21/62] cc-4241: fixed this bug. and maybe 4232 too. --- .../media-monitor2/media/monitor/pure.py | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index 3b97ffe6f..4d768b0f8 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -2,6 +2,7 @@ import copy import os import shutil +import re import sys import hashlib import locale @@ -228,34 +229,33 @@ def normalized_metadata(md, original_path): # Specific rules that are applied in a per attribute basis format_rules = { 'MDATA_KEY_TRACKNUMBER' : parse_int, - 'MDATA_KEY_BITRATE' : lambda x: str(int(x) / 1000) + "kbps", 'MDATA_KEY_FILEPATH' : lambda x: os.path.normpath(x), 'MDATA_KEY_MIME' : lambda x: x.replace('-','/'), 'MDATA_KEY_BPM' : lambda x: x[0:8], } - new_md = remove_whitespace(new_md) + new_md = remove_whitespace(new_md) # remove whitespace fields + # Format all the fields in format_rules new_md = apply_rules_dict(new_md, format_rules) - new_md = default_to(dictionary=new_md, keys=['MDATA_KEY_TITLE'], - default=no_extension_basename(original_path)) - new_md = default_to(dictionary=new_md, keys=['MDATA_KEY_CREATOR', - 'MDATA_KEY_SOURCE'], default=u'') + # set filetype to audioclip by default new_md = default_to(dictionary=new_md, keys=['MDATA_KEY_FTYPE'], default=u'audioclip') - # In the case where the creator is 'Airtime Show Recorder' we would like to - # format the MDATA_KEY_TITLE slightly differently - # Note: I don't know why I'm doing a unicode string comparison here - # that part is copied from the original code + + # Try to parse bpm but delete the whole key if that fails + if 'MDATA_KEY_BPM' in new_md: + new_md['MDATA_KEY_BPM'] = parse_int(new_md['MDATA_KEY_BPM']) + if new_md['MDATA_KEY_BPM'] is None: + del new_md['MDATA_KEY_BPM'] + if is_airtime_recorded(new_md): hour,minute,second,name = new_md['MDATA_KEY_TITLE'].split("-",3) - # We assume that MDATA_KEY_YEAR is always given for airtime recorded - # shows new_md['MDATA_KEY_TITLE'] = u'%s-%s-%s:%s:%s' % \ (name, new_md['MDATA_KEY_YEAR'], hour, minute, second) - # IMPORTANT: in the original code. MDATA_KEY_FILEPATH would also - # be set to the original path of the file for airtime recorded shows - # (before it was "organized"). We will skip this procedure for now - # because it's not clear why it was done + else: + # Read title from filename if it does not exist + new_md = default_to(dictionary=new_md, keys=['MDATA_KEY_TITLE'], + default=no_extension_basename(original_path)) + return new_md def organized_path(old_path, root_path, orig_md): @@ -275,14 +275,21 @@ def organized_path(old_path, root_path, orig_md): else: return True # We set some metadata elements to a default "unknown" value because we use # these fields to create a path hence they cannot be empty + # Here "normal" means normalized only for organized path normal_md = default_to_f(orig_md, path_md, unicode_unknown, default_f) + if normal_md['MDATA_KEY_BITRATE']: + formatted = str(int(normal_md['MDATA_KEY_BITRATE']) / 1000) + normal_md['MDATA_KEY_BITRATE'] = formatted + 'kbps' + else: normal_md['MDATA_KEY_BITRATE'] = unicode_unknown if is_airtime_recorded(normal_md): - fname = u'%s-%s-%s.%s' % ( normal_md['MDATA_KEY_YEAR'], - normal_md['MDATA_KEY_TITLE'], - normal_md['MDATA_KEY_BITRATE'], ext ) + title_re = re.match("(?P\w+)-(?P\d+-\d+-\d+-\d+:\d+:\d+)$", + normal_md['MDATA_KEY_TITLE']) + show_name, = title_re.group('show'), + date = title_re.group('date').replace(':','-') yyyy, mm, _ = normal_md['MDATA_KEY_YEAR'].split('-',2) - path = os.path.join(root_path, yyyy, mm) - filepath = os.path.join(path,fname) + fname_base = '%s-%s-%s.%s' % \ + (date, show_name, normal_md['MDATA_KEY_BITRATE'], ext) + filepath = os.path.join(root_path, yyyy, mm, fname_base) elif len(normal_md['MDATA_KEY_TRACKNUMBER']) == 0: fname = u'%s-%s.%s' % (normal_md['MDATA_KEY_TITLE'], normal_md['MDATA_KEY_BITRATE'], ext) From 12e4585410ae1a59acf0f6213f06691eb7eb4a28 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 14:07:26 -0400 Subject: [PATCH 22/62] MM2: formatted some code --- python_apps/media-monitor2/media/monitor/pure.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index 4d768b0f8..89c859ace 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -274,20 +274,24 @@ def organized_path(old_path, root_path, orig_md): if key in dictionary: return len(dictionary[key]) == 0 else: return True # We set some metadata elements to a default "unknown" value because we use - # these fields to create a path hence they cannot be empty - # Here "normal" means normalized only for organized path + # these fields to create a path hence they cannot be empty Here "normal" + # means normalized only for organized path + + # MDATA_KEY_BITRATE is in bytes/second i.e. (256000) we want to turn this + # into 254kbps normal_md = default_to_f(orig_md, path_md, unicode_unknown, default_f) if normal_md['MDATA_KEY_BITRATE']: formatted = str(int(normal_md['MDATA_KEY_BITRATE']) / 1000) normal_md['MDATA_KEY_BITRATE'] = formatted + 'kbps' else: normal_md['MDATA_KEY_BITRATE'] = unicode_unknown + if is_airtime_recorded(normal_md): title_re = re.match("(?P\w+)-(?P\d+-\d+-\d+-\d+:\d+:\d+)$", normal_md['MDATA_KEY_TITLE']) - show_name, = title_re.group('show'), - date = title_re.group('date').replace(':','-') + show_name, = title_re.group('show'), + date = title_re.group('date').replace(':','-') yyyy, mm, _ = normal_md['MDATA_KEY_YEAR'].split('-',2) - fname_base = '%s-%s-%s.%s' % \ + fname_base = '%s-%s-%s.%s' % \ (date, show_name, normal_md['MDATA_KEY_BITRATE'], ext) filepath = os.path.join(root_path, yyyy, mm, fname_base) elif len(normal_md['MDATA_KEY_TRACKNUMBER']) == 0: From d06f02f1f5a05925ef3c74bde4bb2413dd9de1f0 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 21 Aug 2012 14:08:30 -0400 Subject: [PATCH 23/62] CC-4244: Playlist Builder: Original Length should not be changed after setting Cue in/out value -fixed --- airtime_mvc/application/models/Block.php | 6 +++++- airtime_mvc/application/models/Playlist.php | 13 ++++++++++--- .../application/views/scripts/playlist/update.phtml | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index d5816fab5..28991a0eb 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -192,7 +192,7 @@ class Application_Model_Block $files = array(); $sql = <<<"EOT" - SELECT pc.id as id, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout, bl.type, + SELECT pc.id as id, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout, bl.type, f.length as orig_length, f.id as item_id, f.track_title, f.artist_name as creator, f.file_exists as exists, f.filepath as path FROM cc_blockcontents AS pc LEFT JOIN cc_files AS f ON pc.file_id=f.id LEFT JOIN cc_block AS bl ON pc.block_id = bl.id @@ -220,6 +220,10 @@ EOT; $fades = $this->getFadeInfo($row['position']); $row['fadein'] = $fades[0]; $row['fadeout'] = $fades[1]; + + //format original length + $formatter = new LengthFormatter($row['orig_length']); + $row['orig_length'] = $formatter->format(); } return $rows; diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 29dcd03f8..82bfb4eb3 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -171,7 +171,8 @@ class Application_Model_Playlist f.track_title, f.artist_name AS creator, f.file_exists AS EXISTS, - f.filepath AS path + f.filepath AS path, + f.length AS orig_length FROM cc_playlistcontents AS pc JOIN cc_files AS f ON pc.file_id=f.id WHERE pc.playlist_id = {$this->id} @@ -188,7 +189,8 @@ class Application_Model_Playlist (ws.name || ': ' || ws.url) AS title, sub.login AS creator, 't'::boolean AS EXISTS, - ws.url AS path + ws.url AS path, + ws.length AS orig_length FROM cc_playlistcontents AS pc JOIN cc_webstream AS ws ON pc.stream_id=ws.id LEFT JOIN cc_subjs AS sub ON sub.id = ws.creator_id @@ -206,7 +208,8 @@ class Application_Model_Playlist bl.name AS title, sbj.login AS creator, 't'::boolean AS EXISTS, - NULL::text AS path + NULL::text AS path, + bl.length AS orig_length FROM cc_playlistcontents AS pc JOIN cc_block AS bl ON pc.block_id=bl.id JOIN cc_subjs AS sbj ON bl.creator_id=sbj.id @@ -240,6 +243,10 @@ SQL; $fades = $this->getFadeInfo($row['position']); $row['fadein'] = $fades[0]; $row['fadeout'] = $fades[1]; + + //format original length + $formatter = new LengthFormatter($row['orig_length']); + $row['orig_length'] = $formatter->format(); } return $rows; diff --git a/airtime_mvc/application/views/scripts/playlist/update.phtml b/airtime_mvc/application/views/scripts/playlist/update.phtml index 280437d87..a66b9f94a 100644 --- a/airtime_mvc/application/views/scripts/playlist/update.phtml +++ b/airtime_mvc/application/views/scripts/playlist/update.phtml @@ -55,7 +55,7 @@ if ($item['type'] == 2) { 'id' => $item["id"], 'cueIn' => $item['cuein'], 'cueOut' => $item['cueout'], - 'origLength' => $item['length'])); ?> + 'origLength' => $item['orig_length'])); ?>

From 1090226fc307515654efb45c7e12a9fec8d1a267 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 14:19:11 -0400 Subject: [PATCH 24/62] cc-4255: registered component so that status works --- python_apps/media-monitor2/mm2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python_apps/media-monitor2/mm2.py b/python_apps/media-monitor2/mm2.py index 752076da2..dbfa1ebd5 100644 --- a/python_apps/media-monitor2/mm2.py +++ b/python_apps/media-monitor2/mm2.py @@ -127,6 +127,8 @@ def main(global_config, api_client_config, log_config, tt = ToucherThread(path=config['index_path'], interval=int(config['touch_interval'])) + apiclient.register_component('media-monitor') + pyi = manager.pyinotify() pyi.loop() From 36c3bf5763c2dfa8ee38ae48e5c2bf22b2b1028f Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 15:12:45 -0400 Subject: [PATCH 25/62] cc-4240: added recorder stacktrace print --- python_apps/pypo/recorder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index de48afd1c..e4c1e85f7 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -9,6 +9,7 @@ import sys import pytz import signal import math +import traceback from configobj import ConfigObj @@ -310,6 +311,7 @@ class Recorder(Thread): self.logger.error(e) try: self.handle_message() except Exception, e: + self.logger.error( traceback.format_exc() ) self.logger.error('Pypo Recorder Exception: %s', e) time.sleep(PUSH_INTERVAL) self.loops += 1 From 2cdaa186e32f879dc4bac1870e3d514c4951025b Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 21 Aug 2012 15:42:44 -0400 Subject: [PATCH 26/62] CC-4257: Smart Block: Admin cannot delete DJ user's block -fixed --- .../controllers/PlaylistController.php | 4 ++++ airtime_mvc/application/models/Block.php | 17 +++++++++++++---- airtime_mvc/application/models/Playlist.php | 16 ++++++++++++---- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 28ea6b5f6..2a069d5af 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -140,6 +140,8 @@ class PlaylistController extends Zend_Controller_Action private function playlistNoPermission($p_type) { $this->view->error = "You don't have permission to delete selected {$p_type}(s)."; + $this->changePlaylist(null, $p_type); + $this->createFullResponse(null); } private function playlistUnknownError($e) @@ -294,6 +296,8 @@ class PlaylistController extends Zend_Controller_Action $this->createFullResponse($obj); } catch (PlaylistNoPermissionException $e) { $this->playlistNoPermission($type); + } catch (BlockNoPermissionException $e) { + $this->playlistNoPermission($type); } catch (PlaylistNotFoundException $e) { $this->playlistNotFound($type); } catch (Exception $e) { diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index 28991a0eb..2fc580892 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -875,11 +875,20 @@ EOT; */ public static function deleteBlocks($p_ids, $p_userId) { - $leftOver = self::blocksNotOwnedByUser($p_ids, $p_userId); - if (count($leftOver) == 0) { - CcBlockQuery::create()->findPKs($p_ids)->delete(); + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); + + if (!$isAdminOrPM) { + $leftOver = self::blocksNotOwnedByUser($p_ids, $p_userId); + + if (count($leftOver) == 0) { + CcBlockQuery::create()->findPKs($p_ids)->delete(); + } else { + throw new BlockNoPermissionException; + } } else { - throw new BlockNoPermissionException; + CcBlockQuery::create()->findPKs($p_ids)->delete(); } } diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 82bfb4eb3..fee5211a2 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -874,11 +874,19 @@ SQL; */ public static function deletePlaylists($p_ids, $p_userId) { - $leftOver = self::playlistsNotOwnedByUser($p_ids, $p_userId); - if (count($leftOver) == 0) { - CcPlaylistQuery::create()->findPKs($p_ids)->delete(); + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); + + if (!$isAdminOrPM) { + $leftOver = self::playlistsNotOwnedByUser($p_ids, $p_userId); + if (count($leftOver) == 0) { + CcPlaylistQuery::create()->findPKs($p_ids)->delete(); + } else { + throw new PlaylistNoPermissionException; + } } else { - throw new PlaylistNoPermissionException; + CcPlaylistQuery::create()->findPKs($p_ids)->delete(); } } From 8a0774d298df88d167c8fd25f68ac0eab72068b8 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 15:56:08 -0400 Subject: [PATCH 27/62] cc-4240: Added more tracebacks --- python_apps/pypo/recorder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index e4c1e85f7..4afb76e86 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -157,7 +157,6 @@ class ShowRecorder(Thread): recorded_file.save() except Exception, e: - import traceback top = traceback.format_exc() self.logger.error('Exception: %s', e) self.logger.error("traceback: %s", top) @@ -308,6 +307,7 @@ class Recorder(Thread): self.process_recorder_schedule(temp) self.logger.info("updated recorder schedule received: %s", temp) except Exception, e: + self.logger.error( traceback.format_exc() ) self.logger.error(e) try: self.handle_message() except Exception, e: @@ -316,7 +316,6 @@ class Recorder(Thread): time.sleep(PUSH_INTERVAL) self.loops += 1 except Exception, e : - import traceback top = traceback.format_exc() self.logger.error('Exception: %s', e) self.logger.error("traceback: %s", top) From 64a36ea21aba2e7411a805254f53e6b8dc3ee791 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 16:33:37 -0400 Subject: [PATCH 28/62] cc-4240: fixed --- airtime_mvc/application/models/Show.php | 2 +- python_apps/pypo/recorder.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 874fe2402..8cca2cf69 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1549,7 +1549,7 @@ class Application_Model_Show $sql = $sql." AND ({$exclude})"; } - $result = $con->query($sql); + $result = $con->query($sql)->fetchAll(); return $result; } diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index 4afb76e86..d123b42ef 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -286,6 +286,7 @@ class Recorder(Thread): self.process_recorder_schedule(temp) self.logger.info("Bootstrap recorder schedule received: %s", temp) except Exception, e: + self.logger.error( traceback.format_exc() ) self.logger.error(e) self.logger.info("Bootstrap complete: got initial copy of the schedule") From ffbdba6f6be837126a15ec2bbfa584dd2b902fc6 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 21 Aug 2012 16:37:33 -0400 Subject: [PATCH 29/62] CC-4260: Add-user: Undefined index: ftype -fixed --- airtime_mvc/application/models/Datatables.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/models/Datatables.php b/airtime_mvc/application/models/Datatables.php index 66737b7d9..c4ec7df35 100644 --- a/airtime_mvc/application/models/Datatables.php +++ b/airtime_mvc/application/models/Datatables.php @@ -90,17 +90,21 @@ class Application_Model_Datatables // we need to go over all items and fix length for playlist // in case the playlist contains dynamic block foreach ($results as &$r) { - if ($r['ftype'] == 'playlist') { - $pl = new Application_Model_Playlist($r['id']); - $r['length'] = $pl->getLength(); - } else if ($r['ftype'] == "block") { - $bl = new Application_Model_Block($r['id']); - if ($bl->isStatic()) { - $r['bl_type'] = 'static'; - } else { - $r['bl_type'] = 'dynamic'; + //this function is also called for Manage Users so in + //this case there will be no 'ftype' + if (isset($r['ftype'])) { + if ($r['ftype'] == 'playlist') { + $pl = new Application_Model_Playlist($r['id']); + $r['length'] = $pl->getLength(); + } else if ($r['ftype'] == "block") { + $bl = new Application_Model_Block($r['id']); + if ($bl->isStatic()) { + $r['bl_type'] = 'static'; + } else { + $r['bl_type'] = 'dynamic'; + } + $r['length'] = $bl->getLength(); } - $r['length'] = $bl->getLength(); } } } catch (Exception $e) { From 3871540e62df166d31d5c0aee7090241bf050612 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 16:39:37 -0400 Subject: [PATCH 30/62] big code reformatting in pypo --- python_apps/pypo/recorder.py | 99 ++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index d123b42ef..f5601fa6c 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -56,16 +56,16 @@ class ShowRecorder(Thread): def __init__ (self, show_instance, show_name, filelength, start_time): Thread.__init__(self) - self.logger = logging.getLogger('recorder') - self.api_client = api_client(self.logger) - self.filelength = filelength - self.start_time = start_time + self.logger = logging.getLogger('recorder') + self.api_client = api_client(self.logger) + self.filelength = filelength + self.start_time = start_time self.show_instance = show_instance - self.show_name = show_name - self.p = None + self.show_name = show_name + self.p = None def record_show(self): - length = str(self.filelength) + ".0" + length = str(self.filelength) + ".0" filename = self.start_time filename = filename.replace(" ", "-") @@ -147,10 +147,10 @@ class ShowRecorder(Thread): artist = "Airtime Show Recorder" #set some metadata for our file daemon - recorded_file = mutagen.File(filepath, easy=True) - recorded_file['title'] = name + recorded_file = mutagen.File(filepath, easy = True) + recorded_file['title'] = name recorded_file['artist'] = artist - recorded_file['date'] = md[0] + recorded_file['date'] = md[0] #recorded_file['date'] = md[0].split("-")[0] #You cannot pass ints into the metadata of a file. Even tracknumber needs to be a string recorded_file['tracknumber'] = unicode(self.show_instance) @@ -182,20 +182,20 @@ class ShowRecorder(Thread): class Recorder(Thread): def __init__(self, q): Thread.__init__(self) - self.logger = logging.getLogger('recorder') - self.api_client = api_client(self.logger) - self.api_client.register_component("show-recorder") - self.sr = None + self.logger = logging.getLogger('recorder') + self.api_client = api_client(self.logger) + self.sr = None self.shows_to_record = {} self.server_timezone = '' - self.queue = q + self.queue = q + self.loops = 0 + self.api_client.register_component("show-recorder") self.logger.info("RecorderFetch: init complete") - self.loops = 0 def handle_message(self): if not self.queue.empty(): message = self.queue.get() - msg = json.loads(message) + msg = json.loads(message) command = msg["event_type"] self.logger.info("Received msg from Pypo Message Handler: %s", msg) if command == 'cancel_recording': @@ -214,8 +214,8 @@ class Recorder(Thread): shows = m['shows'] for show in shows: show_starts = getDateTimeObj(show[u'starts']) - show_end = getDateTimeObj(show[u'ends']) - time_delta = show_end - show_starts + show_end = getDateTimeObj(show[u'ends']) + time_delta = show_end - show_starts temp_shows_to_record[show[u'starts']] = [time_delta, show[u'instance_id'], show[u'name'], m['server_timezone']] self.shows_to_record = temp_shows_to_record @@ -225,10 +225,10 @@ class Recorder(Thread): tnow = datetime.datetime.utcnow() sorted_show_keys = sorted(self.shows_to_record.keys()) - start_time = sorted_show_keys[0] - next_show = getDateTimeObj(start_time) + start_time = sorted_show_keys[0] + next_show = getDateTimeObj(start_time) - delta = next_show - tnow + delta = next_show - tnow s = '%s.%s' % (delta.seconds, delta.microseconds) out = float(s) @@ -239,36 +239,35 @@ class Recorder(Thread): return out def start_record(self): - if len(self.shows_to_record) != 0: - try: - delta = self.get_time_till_next_show() - if delta < 5: - self.logger.debug("sleeping %s seconds until show", delta) - time.sleep(delta) + if len(self.shows_to_record) == 0: return None + try: + delta = self.get_time_till_next_show() + if delta < 5: + self.logger.debug("sleeping %s seconds until show", delta) + time.sleep(delta) - sorted_show_keys = sorted(self.shows_to_record.keys()) - start_time = sorted_show_keys[0] - show_length = self.shows_to_record[start_time][0] - show_instance = self.shows_to_record[start_time][1] - show_name = self.shows_to_record[start_time][2] - server_timezone = self.shows_to_record[start_time][3] + sorted_show_keys = sorted(self.shows_to_record.keys()) + start_time = sorted_show_keys[0] + show_length = self.shows_to_record[start_time][0] + show_instance = self.shows_to_record[start_time][1] + show_name = self.shows_to_record[start_time][2] + server_timezone = self.shows_to_record[start_time][3] - T = pytz.timezone(server_timezone) - start_time_on_UTC = getDateTimeObj(start_time) - start_time_on_server = start_time_on_UTC.replace(tzinfo=pytz.utc).astimezone(T) - start_time_formatted = '%(year)d-%(month)02d-%(day)02d %(hour)02d:%(min)02d:%(sec)02d' % \ - {'year': start_time_on_server.year, 'month': start_time_on_server.month, 'day': start_time_on_server.day, \ - 'hour': start_time_on_server.hour, 'min': start_time_on_server.minute, 'sec': start_time_on_server.second} - self.sr = ShowRecorder(show_instance, show_name, show_length.seconds, start_time_formatted) - self.sr.start() - #remove show from shows to record. - del self.shows_to_record[start_time] - #self.time_till_next_show = self.get_time_till_next_show() - except Exception, e : - import traceback - top = traceback.format_exc() - self.logger.error('Exception: %s', e) - self.logger.error("traceback: %s", top) + T = pytz.timezone(server_timezone) + start_time_on_UTC = getDateTimeObj(start_time) + start_time_on_server = start_time_on_UTC.replace(tzinfo=pytz.utc).astimezone(T) + start_time_formatted = '%(year)d-%(month)02d-%(day)02d %(hour)02d:%(min)02d:%(sec)02d' % \ + {'year': start_time_on_server.year, 'month': start_time_on_server.month, 'day': start_time_on_server.day, \ + 'hour': start_time_on_server.hour, 'min': start_time_on_server.minute, 'sec': start_time_on_server.second} + self.sr = ShowRecorder(show_instance, show_name, show_length.seconds, start_time_formatted) + self.sr.start() + #remove show from shows to record. + del self.shows_to_record[start_time] + #self.time_till_next_show = self.get_time_till_next_show() + except Exception, e : + top = traceback.format_exc() + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", top) """ Main loop of the thread: From a1b91aebbd7c69f3b759c7eb1c24fee438b6fac1 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 16:54:14 -0400 Subject: [PATCH 31/62] CC-1665: Scheduled stream rebroadcasting and recording -use sessions to determine currently open object in Library --- airtime_mvc/application/Bootstrap.php | 9 +- .../controllers/LibraryController.php | 4 +- .../controllers/PlaylistController.php | 91 ++----------------- airtime_mvc/application/models/Block.php | 4 +- airtime_mvc/application/models/Playlist.php | 43 +++------ airtime_mvc/application/models/Webstream.php | 25 ++--- 6 files changed, 47 insertions(+), 129 deletions(-) diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 3cc24f73f..9ebf26d10 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -12,7 +12,6 @@ require_once "DateHelper.php"; require_once "OsPath.php"; require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php'; - //DateTime in PHP 5.3.0+ need a default timezone set. Set to UTC initially //in case Application_Model_Preference::GetTimezone fails and creates needs to create //a log entry. This log entry requires a call to date(), which then complains that @@ -67,10 +66,10 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); $baseDir = dirname($_SERVER['SCRIPT_FILENAME']); - $view->headScript()->appendFile($baseUrl.'/js/libs/jquery-1.7.2.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $view->headScript()->appendFile($baseUrl.'/js/libs/jquery-ui-1.8.18.custom.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $view->headScript()->appendFile($baseUrl.'/js/libs/jquery.stickyPanel.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $view->headScript()->appendFile($baseUrl.'/js/qtip/jquery.qtip.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/libs/jquery-1.7.2.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/libs/jquery-ui-1.8.18.custom.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/libs/jquery.stickyPanel.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/qtip/jquery.qtip.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/jplayer/jquery.jplayer.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/sprintf/sprintf-0.7-beta1.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $view->headScript()->appendScript("var baseUrl='$baseUrl/'"); diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 3ba5738bd..cca59e7b5 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -58,8 +58,10 @@ class LibraryController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']); try { + if (isset($this->obj_sess->id)) { - $objInfo = Application_Model_Playlist::getObjInfo($this->obj_sess->type); + $objInfo = Application_Model_Library::getObjInfo($this->obj_sess->type); + Logging::log($this->obj_sess->id); $obj = new $objInfo['className']($this->obj_sess->id); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 28ea6b5f6..3a93d0232 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -2,8 +2,6 @@ class PlaylistController extends Zend_Controller_Action { - /*protected $pl_sess = null; - protected $bl_sess = null;*/ protected $obj_sess = null; public function init() @@ -30,16 +28,13 @@ class PlaylistController extends Zend_Controller_Action ->addActionContext('get-block-info', 'json') ->initContext(); - /*$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); - $this->bl_sess = new Zend_Session_Namespace(UI_BLOCK_SESSNAME);*/ $this->obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); } private function getPlaylist($p_type) { $obj = null; - - $objInfo = Application_Model_Playlist::getObjInfo($p_type); + $objInfo = Application_Model_Library::getObjInfo($p_type); if (isset($this->obj_sess->id)) { $obj = new $objInfo['className']($this->obj_sess->id); @@ -54,16 +49,6 @@ class PlaylistController extends Zend_Controller_Action return $obj; } - private function changePlaylist($p_id, $p_type) - { - if (is_null($p_id) || is_null($p_type)) { - unset($this->obj_sess->id); - unset($this->obj_sess->type); - } else { - $this->obj_sess->id = intval($p_id); - $this->obj_sess->type = $p_type; - } - } private function createUpdateResponse($obj) { @@ -133,7 +118,7 @@ class PlaylistController extends Zend_Controller_Action $this->view->error = "{$p_type} not found"; Logging::log("{$p_type} not found"); - $this->changePlaylist(null, $p_type); + Application_Model_Library::changePlaylist(null, $p_type); $this->createFullResponse(null); } @@ -163,71 +148,13 @@ class PlaylistController extends Zend_Controller_Action $this->createFullResponse($obj); } - public function indexAction() - { - global $CC_CONFIG; - - $request = $this->getRequest(); - $baseUrl = $request->getBaseUrl(); - - $this->view->headScript()->appendFile($baseUrl.'/js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_playlistbuilder.js'), 'text/javascript'); - - $this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); - - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/playlist/smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); - $this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']); - - try { - if (isset($this->obj_sess->id)) { - $objInfo = Application_Model_Playlist::getObjInfo($this->obj_sess->type); - $obj = new $objInfo['className']($this->obj_sess->id); - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new Application_Model_User($userInfo->id); - $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); - - if ($isAdminOrPM || $obj->getCreatorId() == $userInfo->id) { - $this->view->obj = $obj; - if ($this->obj_sess->type == "block") { - $form = new Application_Form_SmartBlockCriteria(); - $form->startForm($this->obj_sess->id); - $this->view->form = $form; - } - } - - $formatter = new LengthFormatter($obj->getLength()); - $this->view->length = $formatter->format(); - $this->view->type = $this->obj_sess->type; - } - } catch (PlaylistNotFoundException $e) { - $this->playlistNotFound($this->obj_sess->type); - } catch (Exception $e) { - $this->playlistUnknownError($e); - } - } - public function newAction() { //$pl_sess = $this->pl_sess; $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $type = $this->_getParam('type'); - $objInfo = Application_Model_Playlist::getObjInfo($type); + $objInfo = Application_Model_Library::getObjInfo($type); $name = 'Untitled Playlist'; if ($type == 'block') { @@ -236,9 +163,9 @@ class PlaylistController extends Zend_Controller_Action $obj = new $objInfo['className'](); $obj->setName($name); - $obj->setMetaData('dc:creator', $userInfo->id); + $obj->setMetadata('dc:creator', $userInfo->id); - $this->changePlaylist($obj->getId(), $type); + Application_Model_Library::changePlaylist($obj->getId(), $type); $this->createFullResponse($obj); } @@ -246,11 +173,11 @@ class PlaylistController extends Zend_Controller_Action { $id = $this->_getParam('id', null); $type = $this->_getParam('type'); - $objInfo = Application_Model_Playlist::getObjInfo($type); + $objInfo = Application_Model_Library::getObjInfo($type); Logging::log("editing {$type} {$id}"); if (!is_null($id)) { - $this->changePlaylist($id, $type); + Application_Model_Library::changePlaylist($id, $type); } try { @@ -271,7 +198,7 @@ class PlaylistController extends Zend_Controller_Action $obj = null; - $objInfo = Application_Model_Playlist::getObjInfo($type); + $objInfo = Application_Model_Library::getObjInfo($type); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -280,7 +207,7 @@ class PlaylistController extends Zend_Controller_Action Logging::log("Currently active {$type} {$this->obj_sess->id}"); if (in_array($this->obj_sess->id, $ids)) { Logging::log("Deleting currently active {$type}"); - $this->changePlaylist(null, $type); + Application_Model_Library::changePlaylist(null, $type); } else { Logging::log("Not deleting currently active {$type}"); $obj = new $objInfo['className']($this->obj_sess->id); diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index d5816fab5..f1941e73d 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -8,7 +8,7 @@ require_once 'formatters/LengthFormatter.php'; * @copyright 2010 Sourcefabric O.P.S. * @license http://www.gnu.org/licenses/gpl.txt */ -class Application_Model_Block +class Application_Model_Block implements Application_Model_LibraryEditable { /** * propel connection object. @@ -839,7 +839,7 @@ EOT; return $this->$method(); } - public function setMetaData($category, $value) + public function setMetadata($category, $value) { $cat = $this->categories[$category]; diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 29dcd03f8..31fdbb6ed 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -8,7 +8,7 @@ require_once 'formatters/LengthFormatter.php'; * @copyright 2010 Sourcefabric O.P.S. * @license http://www.gnu.org/licenses/gpl.txt */ -class Application_Model_Playlist +class Application_Model_Playlist implements Application_Model_LibraryEditable { /** * propel connection object. @@ -270,8 +270,8 @@ SQL; } // returns true/false and ids of dynamic blocks - public function hasDynamicBlock(){ - $ids = $this->getIdsOfDynamicBlocks(); + public function hasDynamicBlock(){ + $ids = $this->getIdsOfDynamicBlocks(); if (count($ids) > 0) { return true; } else { @@ -280,10 +280,10 @@ SQL; } public function getIdsOfDynamicBlocks() { - $sql = "SELECT bl.id FROM cc_playlistcontents as pc - JOIN cc_block as bl ON pc.type=2 AND pc.block_id=bl.id AND bl.type='dynamic' - WHERE playlist_id={$this->id} AND pc.type=2"; - $r = $this->con->query($sql); + $sql = "SELECT bl.id FROM cc_playlistcontents as pc + JOIN cc_block as bl ON pc.type=2 AND pc.block_id=bl.id AND bl.type='dynamic' + WHERE playlist_id={$this->id} AND pc.type=2"; + $r = $this->con->query($sql); $result = $r->fetchAll(PDO::FETCH_ASSOC); return $result; } @@ -425,7 +425,7 @@ SQL; Logging::log("at position {$pos}"); foreach ($p_items as $ac) { - $res = $this->insertPlaylistElement($this->buildEntry($ac, $pos)); + $res = $this->insertPlaylistElement($this->buildEntry($ac, $pos)); $pos = $pos + 1; Logging::log("Adding $ac[1] $ac[0]"); @@ -835,7 +835,7 @@ SQL; return $this->$method(); } - public function setMetaData($category, $value) + public function setMetadata($category, $value) { $cat = $this->categories[$category]; @@ -890,26 +890,13 @@ SQL; return $leftOvers; } - /** - * Delete all files from playlist - * @param int $p_playlistId - */ - public function deleteAllFilesFromPlaylist() + /** + * Delete all files from playlist + * @param int $p_playlistId + */ + public function deleteAllFilesFromPlaylist() { - CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete(); - } - - public static function getObjInfo($p_type) - { - $info = array(); - - if (strcmp($p_type, 'playlist')==0) { - $info['className'] = 'Application_Model_Playlist'; - } else { - $info['className'] = 'Application_Model_Block'; - } - - return $info; + CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete(); } } // class Playlist diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php index a1ca85e59..7d7886e88 100644 --- a/airtime_mvc/application/models/Webstream.php +++ b/airtime_mvc/application/models/Webstream.php @@ -1,7 +1,7 @@ Date: Tue, 21 Aug 2012 16:54:41 -0400 Subject: [PATCH 32/62] CC-1665: Scheduled stream rebroadcasting and recording -verify user that is deleting has current permissions --- .../controllers/WebstreamController.php | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index c195b23c7..9ff877b6c 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -27,6 +27,8 @@ class WebstreamController extends Zend_Controller_Action $webstream->setDbLength("00:00:00"); $webstream->setDbName("Untitled Webstream"); + Application_Model_Library::changePlaylist($obj->getId(), $type); + $this->view->ws = new Application_Model_Webstream($webstream); $this->view->action = "new"; $this->view->html = $this->view->render('webstream/webstream.phtml'); @@ -52,6 +54,14 @@ class WebstreamController extends Zend_Controller_Action $request = $this->getRequest(); $id = $request->getParam("ids"); + if (!$this->isAuthorized($id)) { + header("Status: 401 Not Authorized"); + return; + } + + $type = "stream"; + Application_Model_Library::changePlaylist(null, $type); + $webstream = CcWebstreamQuery::create()->findPK($id)->delete(); $this->view->ws = null; @@ -60,6 +70,28 @@ class WebstreamController extends Zend_Controller_Action } + public function isAuthorized($id) + { + $hasPermission = false; + if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { + $hasPermission = true; + } + + if ($user->isUserType(UTYPE_HOST)) { + if ($id != -1) { + $webstream = CcWebstreamQuery::create()->findPK($id); + //we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission. + $user = Application_Model_User::getCurrentUser(); + + if ($webstream->getDbCreatorId() == $user->getId()) { + $hasPermission = true; + } + } + } + + return $hasPermission; + } + public function saveAction() { $request = $this->getRequest(); @@ -68,11 +100,6 @@ class WebstreamController extends Zend_Controller_Action $user = Application_Model_User::getCurrentUser(); $hasPermission = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST)); - if (!$hasPermission) { - header("Status: 401 Not Authorized"); - return; - } - $id = $request->getParam("id"); $parameters = array(); @@ -82,15 +109,10 @@ class WebstreamController extends Zend_Controller_Action $parameters['description'] = trim($request->getParam("description")); $parameters['url'] = trim($request->getParam("url")); - if ($parameters['id'] != -1) { - $webstream = CcWebstreamQuery::create()->findPK($parameters['id']); - //we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission. - $user = Application_Model_User::getCurrentUser(); - if ($webstream->getDbCreatorId() != $user->getId()) { - header("Status: 401 Not Authorized"); - return; - } - } + if (!$this->isAuthorized($id)) { + header("Status: 401 Not Authorized"); + return; + } list($analysis, $mime, $di) = Application_Model_Webstream::analyzeFormData($parameters); From 9b7413dafaafaa4ca647f963c0204170b49a84cf Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 16:55:10 -0400 Subject: [PATCH 33/62] CC-1665: Scheduled stream rebroadcasting and recording -use sessions to determine currently open object in Library -forgot to check in these files --- airtime_mvc/application/models/Library.php | 35 +++++++++++++++++++ .../application/models/LibraryEditable.php | 8 +++++ 2 files changed, 43 insertions(+) create mode 100644 airtime_mvc/application/models/Library.php create mode 100644 airtime_mvc/application/models/LibraryEditable.php diff --git a/airtime_mvc/application/models/Library.php b/airtime_mvc/application/models/Library.php new file mode 100644 index 000000000..f32b80344 --- /dev/null +++ b/airtime_mvc/application/models/Library.php @@ -0,0 +1,35 @@ +id); + unset($obj_sess->type); + } else { + $obj_sess->id = intval($p_id); + $obj_sess->type = $p_type; + } + } + +} diff --git a/airtime_mvc/application/models/LibraryEditable.php b/airtime_mvc/application/models/LibraryEditable.php new file mode 100644 index 000000000..31af19864 --- /dev/null +++ b/airtime_mvc/application/models/LibraryEditable.php @@ -0,0 +1,8 @@ + Date: Tue, 21 Aug 2012 17:17:20 -0400 Subject: [PATCH 34/62] mm2: removed useless print statement --- python_apps/media-monitor2/tests/test_eventcontractor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python_apps/media-monitor2/tests/test_eventcontractor.py b/python_apps/media-monitor2/tests/test_eventcontractor.py index 58f77856c..2ebef3abf 100644 --- a/python_apps/media-monitor2/tests/test_eventcontractor.py +++ b/python_apps/media-monitor2/tests/test_eventcontractor.py @@ -41,7 +41,6 @@ class TestMMP(unittest.TestCase): self.assertTrue( isinstance(morphed, DeleteFile) ) delete_ev = e1.safe_pack()[0] - print( ev.store ) self.assertEqual( delete_ev['mode'], u'delete') self.assertTrue( len(ev.store.keys()) == 0 ) From e918a56aea482f5ef01c7bf2601ae75c5798680d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 17:23:51 -0400 Subject: [PATCH 35/62] MM2: corrected unit tests --- python_apps/media-monitor2/tests/test_eventcontractor.py | 1 - python_apps/media-monitor2/tests/test_pure.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/python_apps/media-monitor2/tests/test_eventcontractor.py b/python_apps/media-monitor2/tests/test_eventcontractor.py index 2ebef3abf..da35a71d1 100644 --- a/python_apps/media-monitor2/tests/test_eventcontractor.py +++ b/python_apps/media-monitor2/tests/test_eventcontractor.py @@ -64,6 +64,5 @@ class TestMMP(unittest.TestCase): actual_events.append(e) self.assertEqual( len(ev.store.keys()), 1 ) packed = [ x.safe_pack() for x in actual_events ] - print(packed) if __name__ == '__main__': unittest.main() diff --git a/python_apps/media-monitor2/tests/test_pure.py b/python_apps/media-monitor2/tests/test_pure.py index e822f3cf5..70ed9e299 100644 --- a/python_apps/media-monitor2/tests/test_pure.py +++ b/python_apps/media-monitor2/tests/test_pure.py @@ -50,11 +50,11 @@ class TestMMP(unittest.TestCase): }) orga['MDATA_KEY_FTYPE'] = u'audioclip' orig['MDATA_KEY_BITRATE'] = u'256000' - orga['MDATA_KEY_BITRATE'] = u'256kbps' - + orga['MDATA_KEY_BITRATE'] = u'256000' old_path = "/home/rudi/recorded/2012-08-21-11:29:00.ogg" normalized = mmp.normalized_metadata(orig, old_path) - print(normalized) + normalized['MDATA_KEY_BITRATE'] = u'256000' + self.assertEqual( orga, normalized ) organized_base_name = "2012-08-21-11-29-00-record-256kbps.ogg" From c9afe4fa47f8c80d4d3c238c1a2b1b6fbbe5a3c5 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 17:30:05 -0400 Subject: [PATCH 36/62] mm2: sexified tests --- python_apps/media-monitor2/tests/test_pure.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python_apps/media-monitor2/tests/test_pure.py b/python_apps/media-monitor2/tests/test_pure.py index 70ed9e299..59f88dabe 100644 --- a/python_apps/media-monitor2/tests/test_pure.py +++ b/python_apps/media-monitor2/tests/test_pure.py @@ -37,16 +37,16 @@ class TestMMP(unittest.TestCase): def test_normalized_metadata(self): # Recorded show test first orig = Metadata.airtime_dict({ - 'date': [u'2012-08-21'], - 'tracknumber': [u'2'], - 'title': [u'11-29-00-record'], - 'artist': [u'Airtime Show Recorder'] + 'date' : [u'2012-08-21'], + 'tracknumber' : [u'2'], + 'title' : [u'11-29-00-record'], + 'artist' : [u'Airtime Show Recorder'] }) orga = Metadata.airtime_dict({ - 'date': [u'2012-08-21'], - 'tracknumber': [u'2'], - 'artist': [u'Airtime Show Recorder'], - 'title': [u'record-2012-08-21-11:29:00'] + 'date' : [u'2012-08-21'], + 'tracknumber' : [u'2'], + 'artist' : [u'Airtime Show Recorder'], + 'title' : [u'record-2012-08-21-11:29:00'] }) orga['MDATA_KEY_FTYPE'] = u'audioclip' orig['MDATA_KEY_BITRATE'] = u'256000' From 462542bf682b813d49fc9b1f8865daf2f28af78d Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 18:41:56 -0400 Subject: [PATCH 37/62] change Logging::log to Logging::info --- .../application/controllers/ApiController.php | 22 +++++----- .../controllers/PlaylistController.php | 16 ++++---- .../controllers/PlayouthistoryController.php | 4 +- .../controllers/ScheduleController.php | 6 +-- .../controllers/ShowbuilderController.php | 36 ++++++++--------- airtime_mvc/application/logging/Logging.php | 4 +- airtime_mvc/application/models/Block.php | 40 +++++++++---------- airtime_mvc/application/models/Library.php | 2 +- .../application/models/LibraryEditable.php | 2 + airtime_mvc/application/models/LiveLog.php | 8 ++-- airtime_mvc/application/models/Playlist.php | 34 ++++++++-------- airtime_mvc/application/models/Preference.php | 4 +- airtime_mvc/application/models/Schedule.php | 2 +- airtime_mvc/application/models/Scheduler.php | 6 +-- airtime_mvc/application/models/Show.php | 36 ++++++++--------- .../application/models/ShowInstance.php | 6 +-- airtime_mvc/application/models/StoredFile.php | 16 ++++---- .../application/models/StreamSetting.php | 2 +- .../application/models/Systemstatus.php | 2 +- 19 files changed, 125 insertions(+), 123 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index b41129b51..fee9d32c5 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -318,7 +318,7 @@ class ApiController extends Zend_Controller_Action } $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. header("Content-type: text/javascript"); - Logging::log($result); + Logging::info($result); // If a callback is not given, then just provide the raw JSON. echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result); } else { @@ -359,7 +359,7 @@ class ApiController extends Zend_Controller_Action $file->setLastPlayedTime($now); } } catch (Exception $e) { - Logging::log($e); + Logging::info($e); } echo json_encode(array("status"=>1, "message"=>"")); @@ -475,8 +475,8 @@ class ApiController extends Zend_Controller_Action ); } Application_Model_Preference::SetImportTimestamp(); - Logging::log("--->Mode: $mode || file: {$md['MDATA_KEY_FILEPATH']} "); - Logging::log( $md ); + Logging::info("--->Mode: $mode || file: {$md['MDATA_KEY_FILEPATH']} "); + Logging::info( $md ); if ($mode == "create") { $filepath = $md['MDATA_KEY_FILEPATH']; $filepath = Application_Common_OsPath::normpath($filepath); @@ -567,8 +567,8 @@ class ApiController extends Zend_Controller_Action //unset( $info_json["MDATA_KEY_BITRATE"] ); if( !array_key_exists('mode', $info_json) ) { // Log invalid requests - Logging::log("Received bad request(key=$k), no 'mode' parameter. Bad request is:"); - Logging::log( $info_json ); + Logging::info("Received bad request(key=$k), no 'mode' parameter. Bad request is:"); + Logging::info( $info_json ); array_push( $responses, array( 'error' => "Bad request. no 'mode' parameter passed.", 'key' => $k)); @@ -577,8 +577,8 @@ class ApiController extends Zend_Controller_Action // A request still has a chance of being invalid even if it exists but it's validated // by $valid_modes array $mode = $info_json['mode']; - Logging::log("Received bad request(key=$k). 'mode' parameter was invalid with value: '$mode'. Request:"); - Logging::log( $info_json ); + Logging::info("Received bad request(key=$k). 'mode' parameter was invalid with value: '$mode'. Request:"); + Logging::info( $info_json ); array_push( $responses, array( 'error' => "Bad request. 'mode' parameter is invalid", 'key' => $k, @@ -615,7 +615,7 @@ class ApiController extends Zend_Controller_Action } } - Logging::log( $md ); + Logging::info( $md ); // update import timestamp Application_Model_Preference::SetImportTimestamp(); @@ -781,7 +781,7 @@ class ApiController extends Zend_Controller_Action $component = $request->getParam('component'); $remoteAddr = Application_Model_ServiceRegister::GetRemoteIpAddr(); - Logging::log("Registered Component: ".$component."@".$remoteAddr); + Logging::info("Registered Component: ".$component."@".$remoteAddr); Application_Model_ServiceRegister::Register($component, $remoteAddr); } @@ -902,7 +902,7 @@ class ApiController extends Zend_Controller_Action public function rabbitmqDoPushAction() { $request = $this->getRequest(); - Logging::log("Notifying RabbitMQ to send message to pypo"); + Logging::info("Notifying RabbitMQ to send message to pypo"); Application_Model_RabbitMq::PushSchedule(); } diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 85b3c5edb..8631af34c 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -117,7 +117,7 @@ class PlaylistController extends Zend_Controller_Action { $this->view->error = "{$p_type} not found"; - Logging::log("{$p_type} not found"); + Logging::info("{$p_type} not found"); Application_Model_Library::changePlaylist(null, $p_type); $this->createFullResponse(null); } @@ -133,9 +133,9 @@ class PlaylistController extends Zend_Controller_Action { $this->view->error = "Something went wrong."; - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); + Logging::info("{$e->getMessage()}"); } private function wrongTypeToBlock($obj) @@ -176,7 +176,7 @@ class PlaylistController extends Zend_Controller_Action $id = $this->_getParam('id', null); $type = $this->_getParam('type'); $objInfo = Application_Model_Library::getObjInfo($type); - Logging::log("editing {$type} {$id}"); + Logging::info("editing {$type} {$id}"); if (!is_null($id)) { Application_Model_Library::changePlaylist($id, $type); @@ -206,12 +206,12 @@ class PlaylistController extends Zend_Controller_Action $user = new Application_Model_User($userInfo->id); try { - Logging::log("Currently active {$type} {$this->obj_sess->id}"); + Logging::info("Currently active {$type} {$this->obj_sess->id}"); if (in_array($this->obj_sess->id, $ids)) { - Logging::log("Deleting currently active {$type}"); + Logging::info("Deleting currently active {$type}"); Application_Model_Library::changePlaylist(null, $type); } else { - Logging::log("Not deleting currently active {$type}"); + Logging::info("Not deleting currently active {$type}"); $obj = new $objInfo['className']($this->obj_sess->id); } diff --git a/airtime_mvc/application/controllers/PlayouthistoryController.php b/airtime_mvc/application/controllers/PlayouthistoryController.php index ecd0fd4c8..7a046da9b 100644 --- a/airtime_mvc/application/controllers/PlayouthistoryController.php +++ b/airtime_mvc/application/controllers/PlayouthistoryController.php @@ -69,8 +69,8 @@ class PlayouthistoryController extends Zend_Controller_Action $startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); - Logging::log("history starts {$startsDT->format("Y-m-d H:i:s")}"); - Logging::log("history ends {$endsDT->format("Y-m-d H:i:s")}"); + Logging::info("history starts {$startsDT->format("Y-m-d H:i:s")}"); + Logging::info("history ends {$endsDT->format("Y-m-d H:i:s")}"); $history = new Application_Model_PlayoutHistory($startsDT, $endsDT, $params); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 653fdf1e4..83ee7cf91 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -864,9 +864,9 @@ class ScheduleController extends Zend_Controller_Action Application_Model_RabbitMq::SendMessageToPypo("disconnect_source", $data); } catch (Exception $e) { $this->view->error = $e->getMessage(); - Logging::log($e->getMessage()); - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); + Logging::info($e->getMessage()); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); } } } diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index c8dd8f2e9..666a06c2f 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -290,14 +290,14 @@ class ShowbuilderController extends Zend_Controller_Action $scheduler->scheduleAfter($scheduledItems, $mediaItems); } catch (OutDatedScheduleException $e) { $this->view->error = $e->getMessage(); - Logging::log($e->getMessage()); - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); + Logging::info($e->getMessage()); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); } catch (Exception $e) { $this->view->error = $e->getMessage(); - Logging::log($e->getMessage()); - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); + Logging::info($e->getMessage()); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); } } @@ -311,14 +311,14 @@ class ShowbuilderController extends Zend_Controller_Action $scheduler->removeItems($items); } catch (OutDatedScheduleException $e) { $this->view->error = $e->getMessage(); - Logging::log($e->getMessage()); - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); + Logging::info($e->getMessage()); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); } catch (Exception $e) { $this->view->error = $e->getMessage(); - Logging::log($e->getMessage()); - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); + Logging::info($e->getMessage()); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); } } @@ -333,14 +333,14 @@ class ShowbuilderController extends Zend_Controller_Action $scheduler->moveItem($selectedItems, $afterItem); } catch (OutDatedScheduleException $e) { $this->view->error = $e->getMessage(); - Logging::log($e->getMessage()); - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); + Logging::info($e->getMessage()); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); } catch (Exception $e) { $this->view->error = $e->getMessage(); - Logging::log($e->getMessage()); - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); + Logging::info($e->getMessage()); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); } } diff --git a/airtime_mvc/application/logging/Logging.php b/airtime_mvc/application/logging/Logging.php index d6ffff815..9d465fb48 100644 --- a/airtime_mvc/application/logging/Logging.php +++ b/airtime_mvc/application/logging/Logging.php @@ -5,7 +5,7 @@ class Logging { private static $_logger; private static $_path; - public static function getLogger() + private static function getLogger() { if (!isset(self::$_logger)) { $writer = new Zend_Log_Writer_Stream(self::$_path); @@ -37,7 +37,7 @@ class Logging { } } - public static function log($p_msg) + public static function info($p_msg) { $bt = debug_backtrace(); diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index 3bc4d64d2..ea4b71d92 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -188,7 +188,7 @@ class Application_Model_Block implements Application_Model_LibraryEditable */ public function getContents($filterFiles=false) { - Logging::log("Getting contents for block {$this->id}"); + Logging::info("Getting contents for block {$this->id}"); $files = array(); $sql = <<<"EOT" @@ -387,11 +387,11 @@ EOT; try { if (is_numeric($p_afterItem)) { - Logging::log("Finding block content item {$p_afterItem}"); + Logging::info("Finding block content item {$p_afterItem}"); $afterItem = CcBlockcontentsQuery::create()->findPK($p_afterItem); $index = $afterItem->getDbPosition(); - Logging::log("index is {$index}"); + Logging::info("index is {$index}"); $pos = ($addType == 'after') ? $index + 1 : $index; $contentsToUpdate = CcBlockcontentsQuery::create() @@ -400,8 +400,8 @@ EOT; ->orderByDbPosition() ->find($this->con); - Logging::log("Adding to block"); - Logging::log("at position {$pos}"); + Logging::info("Adding to block"); + Logging::info("at position {$pos}"); } else { //add to the end of the block @@ -424,12 +424,12 @@ EOT; ->orderByDbPosition() ->find($this->con); - Logging::log("Adding to block"); - Logging::log("at position {$pos}"); + Logging::info("Adding to block"); + Logging::info("at position {$pos}"); } foreach ($p_items as $ac) { - Logging::log("Adding audio file {$ac}"); + Logging::info("Adding audio file {$ac}"); if (is_array($ac) && $ac[1] == 'audioclip') { $res = $this->insertBlockElement($this->buildEntry($ac[0], $pos)); @@ -485,32 +485,32 @@ EOT; $pos = 0; //moving items to beginning of the block. if (is_null($p_afterItem)) { - Logging::log("moving items to beginning of block"); + Logging::info("moving items to beginning of block"); foreach ($contentsToMove as $item) { - Logging::log("item {$item->getDbId()} to pos {$pos}"); + Logging::info("item {$item->getDbId()} to pos {$pos}"); $item->setDbPosition($pos); $item->save($this->con); $pos = $pos + 1; } foreach ($otherContent as $item) { - Logging::log("item {$item->getDbId()} to pos {$pos}"); + Logging::info("item {$item->getDbId()} to pos {$pos}"); $item->setDbPosition($pos); $item->save($this->con); $pos = $pos + 1; } } else { - Logging::log("moving items after {$p_afterItem}"); + Logging::info("moving items after {$p_afterItem}"); foreach ($otherContent as $item) { - Logging::log("item {$item->getDbId()} to pos {$pos}"); + Logging::info("item {$item->getDbId()} to pos {$pos}"); $item->setDbPosition($pos); $item->save($this->con); $pos = $pos + 1; if ($item->getDbId() == $p_afterItem) { foreach ($contentsToMove as $move) { - Logging::log("item {$move->getDbId()} to pos {$pos}"); + Logging::info("item {$move->getDbId()} to pos {$pos}"); $move->setDbPosition($pos); $move->save($this->con); $pos = $pos + 1; @@ -570,7 +570,7 @@ EOT; public function getFadeInfo($pos) { - Logging::log("Getting fade info for pos {$pos}"); + Logging::info("Getting fade info for pos {$pos}"); $row = CcBlockcontentsQuery::create() ->joinWith(CcFilesPeer::OM_CLASS) @@ -655,7 +655,7 @@ EOT; public function setfades($fadein, $fadeout) { if (isset($fadein)) { - Logging::log("Setting block fade in {$fadein}"); + Logging::info("Setting block fade in {$fadein}"); $row = CcBlockcontentsQuery::create() ->filterByDbBlockId($this->id) ->filterByDbPosition(0) @@ -665,7 +665,7 @@ EOT; } if (isset($fadeout)) { - Logging::log("Setting block fade out {$fadeout}"); + Logging::info("Setting block fade out {$fadeout}"); $row = CcBlockcontentsQuery::create() ->filterByDbBlockId($this->id) ->filterByDbPosition($this->getSize()-1) @@ -992,7 +992,7 @@ EOT; public function storeCriteriaIntoDb($p_criteriaData){ // delete criteria under $p_blockId CcBlockcriteriaQuery::create()->findByDbBlockId($this->id)->delete(); - Logging::log($p_criteriaData); + Logging::info($p_criteriaData); //insert modifier rows if (isset($p_criteriaData['criteria'])) { $critKeys = array_keys($p_criteriaData['criteria']); @@ -1188,7 +1188,7 @@ EOT; $qry->add($spCriteria, $spCriteriaValue, $spCriteriaModifier); } }catch (Exception $e){ - Logging::log($e); + Logging::info($e); } $i++; } @@ -1210,7 +1210,7 @@ EOT; $out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find(); return array("files"=>$out, "limit"=>$limits, "count"=>$out->count()); }catch(Exception $e){ - Logging::log($e); + Logging::info($e); } } diff --git a/airtime_mvc/application/models/Library.php b/airtime_mvc/application/models/Library.php index f32b80344..27e22400f 100644 --- a/airtime_mvc/application/models/Library.php +++ b/airtime_mvc/application/models/Library.php @@ -21,7 +21,7 @@ class Application_Model_Library public static function changePlaylist($p_id, $p_type) { $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); - Logging::log($obj_sess); + Logging::info($obj_sess); if (is_null($p_id) || is_null($p_type)) { unset($obj_sess->id); diff --git a/airtime_mvc/application/models/LibraryEditable.php b/airtime_mvc/application/models/LibraryEditable.php index 31af19864..9fb952a71 100644 --- a/airtime_mvc/application/models/LibraryEditable.php +++ b/airtime_mvc/application/models/LibraryEditable.php @@ -5,4 +5,6 @@ interface Application_Model_LibraryEditable public function setMetadata($key, $val); public function setName($name); + public function getLength(); + public function getId(); } diff --git a/airtime_mvc/application/models/LiveLog.php b/airtime_mvc/application/models/LiveLog.php index 25a25c268..fd95e4ff6 100644 --- a/airtime_mvc/application/models/LiveLog.php +++ b/airtime_mvc/application/models/LiveLog.php @@ -96,7 +96,7 @@ class Application_Model_LiveLog return $minutes; } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); - Logging::log("GetLiveShowDuration - Could not connect to database."); + Logging::info("GetLiveShowDuration - Could not connect to database."); exit; } } @@ -254,7 +254,7 @@ class Application_Model_LiveLog return $minutes; } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); - Logging::log("GetScheduledDuration - Could not connect to database."); + Logging::info("GetScheduledDuration - Could not connect to database."); exit; } } @@ -301,7 +301,7 @@ class Application_Model_LiveLog } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); - Logging::log("SetNewLogTime - Could not connect to database."); + Logging::info("SetNewLogTime - Could not connect to database."); exit; } } @@ -338,7 +338,7 @@ class Application_Model_LiveLog } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); - Logging::log("SetEndTime - Could not connect to database."); + Logging::info("SetEndTime - Could not connect to database."); exit; } } diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index a8d35adee..5d716b107 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -135,8 +135,8 @@ class Application_Model_Playlist implements Application_Model_LibraryEditable public function getLastModified($format = null) { - //Logging::log($this->pl->getDbMtime($format)); - //Logging::log($this->pl); + //Logging::info($this->pl->getDbMtime($format)); + //Logging::info($this->pl); return $this->pl->getDbMtime($format); } @@ -153,7 +153,7 @@ class Application_Model_Playlist implements Application_Model_LibraryEditable */ public function getContents($filterFiles=false) { - Logging::log("Getting contents for playlist {$this->id}"); + Logging::info("Getting contents for playlist {$this->id}"); $files = array(); $sql = <<findPK($p_afterItem); $index = $afterItem->getDbPosition(); - Logging::log("index is {$index}"); + Logging::info("index is {$index}"); $pos = ($addType == 'after') ? $index + 1 : $index; $contentsToUpdate = CcPlaylistcontentsQuery::create() @@ -428,13 +428,13 @@ SQL; } - Logging::log("Adding to playlist"); - Logging::log("at position {$pos}"); + Logging::info("Adding to playlist"); + Logging::info("at position {$pos}"); foreach ($p_items as $ac) { $res = $this->insertPlaylistElement($this->buildEntry($ac, $pos)); $pos = $pos + 1; - Logging::log("Adding $ac[1] $ac[0]"); + Logging::info("Adding $ac[1] $ac[0]"); } @@ -483,32 +483,32 @@ SQL; $pos = 0; //moving items to beginning of the playlist. if (is_null($p_afterItem)) { - Logging::log("moving items to beginning of playlist"); + Logging::info("moving items to beginning of playlist"); foreach ($contentsToMove as $item) { - Logging::log("item {$item->getDbId()} to pos {$pos}"); + Logging::info("item {$item->getDbId()} to pos {$pos}"); $item->setDbPosition($pos); $item->save($this->con); $pos = $pos + 1; } foreach ($otherContent as $item) { - Logging::log("item {$item->getDbId()} to pos {$pos}"); + Logging::info("item {$item->getDbId()} to pos {$pos}"); $item->setDbPosition($pos); $item->save($this->con); $pos = $pos + 1; } } else { - Logging::log("moving items after {$p_afterItem}"); + Logging::info("moving items after {$p_afterItem}"); foreach ($otherContent as $item) { - Logging::log("item {$item->getDbId()} to pos {$pos}"); + Logging::info("item {$item->getDbId()} to pos {$pos}"); $item->setDbPosition($pos); $item->save($this->con); $pos = $pos + 1; if ($item->getDbId() == $p_afterItem) { foreach ($contentsToMove as $move) { - Logging::log("item {$move->getDbId()} to pos {$pos}"); + Logging::info("item {$move->getDbId()} to pos {$pos}"); $move->setDbPosition($pos); $move->save($this->con); $pos = $pos + 1; @@ -568,7 +568,7 @@ SQL; public function getFadeInfo($pos) { - Logging::log("Getting fade info for pos {$pos}"); + Logging::info("Getting fade info for pos {$pos}"); $row = CcPlaylistcontentsQuery::create() ->joinWith(CcFilesPeer::OM_CLASS) @@ -654,7 +654,7 @@ SQL; public function setfades($fadein, $fadeout) { if (isset($fadein)) { - Logging::log("Setting playlist fade in {$fadein}"); + Logging::info("Setting playlist fade in {$fadein}"); $row = CcPlaylistcontentsQuery::create() ->filterByDbPlaylistId($this->id) ->filterByDbPosition(0) @@ -664,7 +664,7 @@ SQL; } if (isset($fadeout)) { - Logging::log("Setting playlist fade out {$fadeout}"); + Logging::info("Setting playlist fade out {$fadeout}"); $row = CcPlaylistcontentsQuery::create() ->filterByDbPlaylistId($this->id) ->filterByDbPosition($this->getSize()-1) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index df3b1fdde..60ece9575 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -66,7 +66,7 @@ class Application_Model_Preference } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); - Logging::log("Could not connect to database: ".$e->getMessage()); + Logging::info("Could not connect to database: ".$e->getMessage()); exit; } @@ -107,7 +107,7 @@ class Application_Model_Preference } } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); - Logging::log("Could not connect to database: ".$e->getMessage()); + Logging::info("Could not connect to database: ".$e->getMessage()); exit; } } diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index ea3160007..f5f4ee501 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -32,7 +32,7 @@ class Application_Model_Schedule { if (!is_int($p_prev) || !is_int($p_next)) { //must enter integers to specify ranges - Logging::log("Invalid range parameters: $p_prev or $p_next"); + Logging::info("Invalid range parameters: $p_prev or $p_next"); return array(); } diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index e995b88ed..60ff886da 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -110,7 +110,7 @@ class Application_Model_Scheduler $ts = intval($instanceInfo[$id]); $lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0; if ($ts < $lastSchedTs) { - Logging::log("ts {$ts} last sched {$lastSchedTs}"); + Logging::info("ts {$ts} last sched {$lastSchedTs}"); throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!"); } } @@ -317,7 +317,7 @@ class Application_Model_Scheduler */ private function removeGaps($showInstance, $exclude=null) { - Logging::log("removing gaps from show instance #".$showInstance); + Logging::info("removing gaps from show instance #".$showInstance); $instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con); if (is_null($instance)) { @@ -416,7 +416,7 @@ class Application_Model_Scheduler } else { $sched = new CcSchedule(); } - Logging::log($file); + Logging::info($file); $sched->setDbStarts($nextStartDT) ->setDbEnds($endTimeDT) ->setDbCueIn($file['cuein']) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 8cca2cf69..86e32965e 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -216,8 +216,8 @@ class Application_Model_Show $con->commit(); } catch (Exception $e) { $con->rollback(); - Logging::log("Couldn't update schedule status."); - Logging::log($e->getMessage()); + Logging::info("Couldn't update schedule status."); + Logging::info($e->getMessage()); } Application_Model_RabbitMq::PushSchedule(); @@ -277,27 +277,27 @@ class Application_Model_Show ->filterByDbShowId($this->getId()) ->find(); - Logging::log("Unchecked days:"); + Logging::info("Unchecked days:"); foreach ($p_uncheckedDays as $day) { - Logging::log($day); + Logging::info($day); } foreach ($showDays as $showDay) { - //Logging::log("Local show day is: {$showDay->getDbDay()}"); - //Logging::log("First show day is: {$showDay->getDbFirstShow()}"); - //Logging::log("Id show days is: {$showDay->getDbId()}"); + //Logging::info("Local show day is: {$showDay->getDbDay()}"); + //Logging::info("First show day is: {$showDay->getDbFirstShow()}"); + //Logging::info("Id show days is: {$showDay->getDbId()}"); if (in_array($showDay->getDbDay(), $p_uncheckedDays)) { $showDay->reload(); - //Logging::log("Local show day is: {$showDay->getDbDay()}"); - //Logging::log("First show day is: {$showDay->getDbFirstShow()}"); - //Logging::log("Id show days is: {$showDay->getDbId()}"); + //Logging::info("Local show day is: {$showDay->getDbDay()}"); + //Logging::info("First show day is: {$showDay->getDbFirstShow()}"); + //Logging::info("Id show days is: {$showDay->getDbId()}"); $startDay = new DateTime("{$showDay->getDbFirstShow()} {$showDay->getDbStartTime()}", new DateTimeZone($showDay->getDbTimezone())); - //Logging::log("Show start day: {$startDay->format('Y-m-d H:i:s')}"); + //Logging::info("Show start day: {$startDay->format('Y-m-d H:i:s')}"); $startDay->setTimezone(new DateTimeZone("UTC")); - //Logging::log("Show start day UTC: {$startDay->format('Y-m-d H:i:s')}"); + //Logging::info("Show start day UTC: {$startDay->format('Y-m-d H:i:s')}"); $daysRemovedUTC[] = $startDay->format('w'); - //Logging::log("UTC show day is: {$startDay->format('w')}"); + //Logging::info("UTC show day is: {$startDay->format('w')}"); } } @@ -368,7 +368,7 @@ class Application_Model_Show ."WHERE instance_id = (SELECT id FROM cc_show_instances WHERE show_id = $showId ORDER BY starts LIMIT 1) AND rebroadcast = 1 " ."ORDER BY starts"; - //Logging::log($sql); + //Logging::info($sql); $rebroadcasts = $con->query($sql)->fetchAll(); @@ -1160,8 +1160,8 @@ class Application_Model_Show $con->commit(); } catch (Exception $e) { $con->rollback(); - Logging::log("Couldn't update schedule status."); - Logging::log($e->getMessage()); + Logging::info("Couldn't update schedule status."); + Logging::info($e->getMessage()); } } @@ -1590,7 +1590,7 @@ class Application_Model_Show WHERE last_show IS NULL OR first_show < '{$endTimeString}' AND last_show > '{$startTimeString}'"; - //Logging::log($sql); + //Logging::info($sql); $res = $con->query($sql)->fetchAll(); foreach ($res as $row) { Application_Model_Show::populateShow($row, $p_endTimestamp); @@ -1723,7 +1723,7 @@ class Application_Model_Show $showDay->setDbFirstShow($dt)->setDbStartTime($dt) ->save(); - //Logging::log("setting show's first show."); + //Logging::info("setting show's first show."); } /* Takes in a UTC DateTime object diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 6d3f988c0..f6fd10491 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -571,9 +571,9 @@ class Application_Model_ShowInstance $rebroad = new Application_Model_ShowInstance($rebroadcast->getDbId()); $rebroad->addFileToShow($file_id, false); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); + Logging::info("{$e->getMessage()}"); } } } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 7b06455ff..642212fc5 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -96,7 +96,7 @@ class Application_Model_StoredFile */ public function setMetadata($p_md=null) { - Logging::log("entered setMetadata"); + Logging::info("entered setMetadata"); if (is_null($p_md)) { $this->setDbColMetadata(); } else { @@ -153,7 +153,7 @@ class Application_Model_StoredFile if (isset($this->_dbMD[$dbColumn])) { $propelColumn = $this->_dbMD[$dbColumn]; $method = "set$propelColumn"; - Logging::log($method); + Logging::info($method); $this->_file->$method($mdValue); } } @@ -446,7 +446,7 @@ class Application_Model_StoredFile */ public function getRelativeFileUrl($baseUrl) { - Logging::log("getting media!"); + Logging::info("getting media!"); return $baseUrl."/api/get-media/file/".$this->getId().".".$this->getFileExtension(); } @@ -760,7 +760,7 @@ class Application_Model_StoredFile $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0; $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0; $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; - Logging::log(__FILE__.":uploadFile(): filename=$fileName to $p_targetDir"); + Logging::info(__FILE__.":uploadFile(): filename=$fileName to $p_targetDir"); // Clean the fileName for security reasons //this needs fixing for songs not in ascii. //$fileName = preg_replace('/[^\w\._]+/', '', $fileName); @@ -852,7 +852,7 @@ class Application_Model_StoredFile public static function copyFileToStor($p_targetDir, $fileName, $tempname) { $audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $tempname; - Logging::log('copyFileToStor: moving file '.$audio_file); + Logging::info('copyFileToStor: moving file '.$audio_file); $md5 = md5_file($audio_file); $duplicate = Application_Model_StoredFile::RecallByMd5($md5, true); @@ -877,7 +877,7 @@ class Application_Model_StoredFile } if (chmod($audio_file, 0644) === false) { - Logging::log("Warning: couldn't change permissions of $audio_file to 0644"); + Logging::info("Warning: couldn't change permissions of $audio_file to 0644"); } //check to see if there is enough space in $stor to continue. @@ -886,7 +886,7 @@ class Application_Model_StoredFile if (self::liquidsoapFilePlayabilityTest($audio_file)) { - Logging::log("copyFileToStor: moving file $audio_file to $audio_stor"); + Logging::info("copyFileToStor: moving file $audio_file to $audio_stor"); //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation if (@rename($audio_file, $audio_stor) === false) { @@ -1004,7 +1004,7 @@ class Application_Model_StoredFile return count($rows); } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); - Logging::log("Could not connect to database."); + Logging::info("Could not connect to database."); exit; } diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index cdbee0106..f1d5362c5 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -66,7 +66,7 @@ class Application_Model_StreamSetting $ids[] = substr($row["keyname"], 0, strpos($row["keyname"], "_")); } - //Logging::log(print_r($ids, true)); + //Logging::info(print_r($ids, true)); return $ids; } diff --git a/airtime_mvc/application/models/Systemstatus.php b/airtime_mvc/application/models/Systemstatus.php index 6c97605c2..d62ad7110 100644 --- a/airtime_mvc/application/models/Systemstatus.php +++ b/airtime_mvc/application/models/Systemstatus.php @@ -224,7 +224,7 @@ class Application_Model_Systemstatus $partitions[$totalSpace]->totalSpace = $totalSpace; $partitions[$totalSpace]->totalFreeSpace = $totalSpace - $usedSpace; - Logging::log($partitions[$totalSpace]->totalFreeSpace); + Logging::info($partitions[$totalSpace]->totalFreeSpace); } else { /* First lets get all the watched directories. Then we can group them * into the same partitions by comparing the partition sizes. */ From 9885374d34b221bfd8ea95bf129dd89fa955bfe8 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 21 Aug 2012 18:55:38 -0400 Subject: [PATCH 38/62] CC-1665: Scheduled stream rebroadcasting and recording -more work to make webstreams behave like playlist creator --- .../controllers/LibraryController.php | 9 ++++--- .../controllers/WebstreamController.php | 26 ++++++++++++++----- airtime_mvc/application/models/Webstream.php | 11 ++++++++ .../views/scripts/library/index.phtml | 18 +++++++++---- .../views/scripts/webstream/webstream.phtml | 18 ++++++------- 5 files changed, 57 insertions(+), 25 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index cca59e7b5..a23f2f1a7 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -60,8 +60,9 @@ class LibraryController extends Zend_Controller_Action try { if (isset($this->obj_sess->id)) { + Logging::info($this->obj_sess->type); $objInfo = Application_Model_Library::getObjInfo($this->obj_sess->type); - Logging::log($this->obj_sess->id); + Logging::info($this->obj_sess->id); $obj = new $objInfo['className']($this->obj_sess->id); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -252,7 +253,7 @@ class LibraryController extends Zend_Controller_Action Application_Model_Webstream::deleteStreams($streams, $user->getId()); } catch (Exception $e) { //TODO: warn user that not all streams could be deleted. - Logging::log($e); + Logging::info($e); } foreach ($files as $id) { @@ -328,7 +329,7 @@ class LibraryController extends Zend_Controller_Action // set MDATA_KEY_FILEPATH $data['MDATA_KEY_FILEPATH'] = $file->getFilePath(); - Logging::log($data['MDATA_KEY_FILEPATH']); + Logging::info($data['MDATA_KEY_FILEPATH']); Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data); $this->_redirect('Library'); @@ -405,7 +406,7 @@ class LibraryController extends Zend_Controller_Action $this->view->type = $type; } } catch (Exception $e) { - Logging::log($e->getMessage()); + Logging::info($e->getMessage()); } } diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index 9ff877b6c..5ab8213db 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -10,26 +10,37 @@ class WebstreamController extends Zend_Controller_Action ->addActionContext('edit', 'json') ->addActionContext('delete', 'json') ->initContext(); - //TODO - //$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); } public function newAction() { + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $webstream = new CcWebstream(); //we're not saving this primary key in the DB so it's OK - $webstream->setDbId(-1); + //$webstream->setDbId(-1); $webstream->setDbName("Untitled Webstream"); $webstream->setDbDescription(""); $webstream->setDbUrl("http://"); $webstream->setDbLength("00:00:00"); $webstream->setDbName("Untitled Webstream"); + $webstream->setDbCreatorId($userInfo->id); + $webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC'))); + $webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC'))); + $webstream->save(); + $type = "stream"; + $objInfo = Application_Model_Library::getObjInfo($type); + + $obj = new $objInfo['className']($webstream); + $obj->setName($webstream->getDbName()); + $obj->setMetadata('dc:creator', $userInfo->id); + + $type = "stream"; Application_Model_Library::changePlaylist($obj->getId(), $type); - $this->view->ws = new Application_Model_Webstream($webstream); + $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "new"; $this->view->html = $this->view->render('webstream/webstream.phtml'); } @@ -44,7 +55,7 @@ class WebstreamController extends Zend_Controller_Action } $webstream = CcWebstreamQuery::create()->findPK($id); - $this->view->ws = new Application_Model_Webstream($webstream); + $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "edit"; $this->view->html = $this->view->render('webstream/webstream.phtml'); } @@ -64,7 +75,7 @@ class WebstreamController extends Zend_Controller_Action $webstream = CcWebstreamQuery::create()->findPK($id)->delete(); - $this->view->ws = null; + $this->view->obj = null; $this->view->action = "delete"; $this->view->html = $this->view->render('webstream/webstream.phtml'); @@ -73,11 +84,12 @@ class WebstreamController extends Zend_Controller_Action public function isAuthorized($id) { $hasPermission = false; + $user = Application_Model_User::getCurrentUser(); if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $hasPermission = true; } - if ($user->isUserType(UTYPE_HOST)) { + if (!$hasPermission) { if ($id != -1) { $webstream = CcWebstreamQuery::create()->findPK($id); //we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission. diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php index 7d7886e88..25279686e 100644 --- a/airtime_mvc/application/models/Webstream.php +++ b/airtime_mvc/application/models/Webstream.php @@ -6,7 +6,13 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable public function __construct($webstream) { + //TODO: hacky... + Logging::info("x ".$webstream); + if (is_int($webstream)) { + $this->webstream = CcWebstreamQuery::create()->findPK($webstream); + } else { $this->webstream = $webstream; + } } public function getOrm() @@ -41,6 +47,11 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable return ""; } + public function getLength() + { + return $this->getDefaultLength(); + } + public function getDescription() { return $this->webstream->getDbDescription(); diff --git a/airtime_mvc/application/views/scripts/library/index.phtml b/airtime_mvc/application/views/scripts/library/index.phtml index dd7c9f5f1..6f1d9dcbf 100644 --- a/airtime_mvc/application/views/scripts/library/index.phtml +++ b/airtime_mvc/application/views/scripts/library/index.phtml @@ -4,8 +4,16 @@
type == 'block') { - echo $this->render('playlist/smart-block.phtml'); - } else { - echo $this->render('playlist/playlist.phtml'); - } ?> -
\ No newline at end of file + echo $this->render('playlist/smart-block.phtml'); + } else if ($this->type == 'playlist') { + echo $this->render('playlist/playlist.phtml'); + } else if ($this->type == 'stream') { + echo $this->render('webstream/webstream.phtml'); + } else { + echo $this->render('webstream/webstream.phtml'); + //throw new Exception("Unrecognized type: '{$this->type}'"); + } + + +?> + diff --git a/airtime_mvc/application/views/scripts/webstream/webstream.phtml b/airtime_mvc/application/views/scripts/webstream/webstream.phtml index 939cfffde..876ee841c 100644 --- a/airtime_mvc/application/views/scripts/webstream/webstream.phtml +++ b/airtime_mvc/application/views/scripts/webstream/webstream.phtml @@ -1,20 +1,20 @@ -ws)) : ?> +obj)) : ?> -ws)) : ?> - - ws->getLastModified('U'); ?>"> +obj)) : ?> + + obj->getLastModified('U'); ?>">

- ws->getName(); ?> + obj->getName(); ?>

-

ws->getDefaultLength(); ?>

+

obj->getDefaultLength(); ?>

@@ -22,18 +22,18 @@
- +
- +
- +
From 73e52adee17b08ba043dcfcae7ee96b2b9b0980f Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 10:39:26 -0400 Subject: [PATCH 39/62] Upgraded version number to 2.2.0 --- install_minimal/include/airtime-constants.php | 2 +- .../include/airtime-installed-check.php | 4 ++-- .../upgrades/airtime-2.1.3/data/upgrade.sql | 2 +- .../airtime-2.2.0/common/UpgradeCommon.php | 16 ++++++++-------- python_apps/api_clients/api_client.py | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/install_minimal/include/airtime-constants.php b/install_minimal/include/airtime-constants.php index 1d09fca25..8d028ec63 100644 --- a/install_minimal/include/airtime-constants.php +++ b/install_minimal/include/airtime-constants.php @@ -1,3 +1,3 @@ Date: Wed, 22 Aug 2012 11:42:30 -0400 Subject: [PATCH 40/62] MM2: removed shit comments. --- python_apps/media-monitor2/media/monitor/eventcontractor.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/eventcontractor.py b/python_apps/media-monitor2/media/monitor/eventcontractor.py index 7e444b3ea..9eb181bf4 100644 --- a/python_apps/media-monitor2/media/monitor/eventcontractor.py +++ b/python_apps/media-monitor2/media/monitor/eventcontractor.py @@ -57,8 +57,4 @@ class EventContractor(Loggable): def __unregister(self, evt): try: del self.store[evt.path] - except Exception as e: - self.unexpected_exception(e) - # the next line is commented out because it clutters up logging real - # bad - #self.logger.info("Unregistering. Left: '%d'" % len(self.store.keys())) + except Exception as e: self.unexpected_exception(e) From 22eea4e4326465ad9d3ad442aa5253bdadf38704 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 11:43:32 -0400 Subject: [PATCH 41/62] -fixed wrong copying in upgrade skip (see comment in code) -improved config copying procedure. more general, better error reporting. --- .../airtime-2.2.0/common/UpgradeCommon.php | 101 +++++++++++++++--- 1 file changed, 85 insertions(+), 16 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php b/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php index de1514333..4f30c2b8e 100644 --- a/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php +++ b/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php @@ -86,7 +86,9 @@ class UpgradeCommon{ $configFiles = array(UpgradeCommon::CONF_FILE_AIRTIME, UpgradeCommon::CONF_FILE_PYPO, - UpgradeCommon::CONF_FILE_LIQUIDSOAP, + //this is not necessary because liquidsoap configs + //are automatically generated + //UpgradeCommon::CONF_FILE_LIQUIDSOAP, UpgradeCommon::CONF_FILE_MEDIAMONITOR, UpgradeCommon::CONF_FILE_API_CLIENT); @@ -118,21 +120,22 @@ class UpgradeCommon{ } } - if (!copy(__DIR__."/../etc/airtime.conf.$suffix", self::CONF_FILE_AIRTIME)){ - echo "Could not copy airtime.conf to /etc/airtime/. Exiting."; - exit(1); - } - if (!copy(__DIR__."/../etc/pypo.cfg.$suffix", self::CONF_FILE_PYPO)){ - echo "Could not copy pypo.cfg to /etc/airtime/. Exiting."; - exit(1); - } - if (!copy(__DIR__."/../etc/media-monitor.cfg.$suffix", self::CONF_FILE_MEDIAMONITOR)){ - echo "Could not copy meadia-monitor.cfg to /etc/airtime/. Exiting."; - exit(1); - } - if (!copy(__DIR__."/../etc/api_client.cfg.$suffix", self::CONF_FILE_API_CLIENT)){ - echo "Could not copy api_client.cfg to /etc/monit/conf.d/. Exiting."; - exit(1); + $config_copy = array( + "../etc/airtime.conf" => self::CONF_FILE_AIRTIME, + "../etc/pypo.cfg" => self::CONF_FILE_PYPO, + "../etc/media-monitor.cfg" => self::CONF_FILE_MEDIAMONITOR, + "../etc/api_client.cfg" => self::CONF_FILE_API_CLIENT + ); + + echo "Copying configs:"; + foreach ($config_copy as $path_part => $destination) { + $full_path = OsPath::normpath(OsPath::join(__DIR__, + "$path_part.$suffix")); + echo "'$full_path' --> '$destination'\n"; + if(!copy($full_path, $destination)) { + echo "Failed on the copying operation above\n"; + exit(1); + } } } @@ -244,3 +247,69 @@ class UpgradeCommon{ return $result; } } + +class OsPath { + // this function is from http://stackoverflow.com/questions/2670299/is-there-a-php-equivalent-function-to-the-python-os-path-normpath + public static function normpath($path) + { + if (empty($path)) + return '.'; + + if (strpos($path, '/') === 0) + $initial_slashes = true; + else + $initial_slashes = false; + if ( + ($initial_slashes) && + (strpos($path, '//') === 0) && + (strpos($path, '///') === false) + ) + $initial_slashes = 2; + $initial_slashes = (int) $initial_slashes; + + $comps = explode('/', $path); + $new_comps = array(); + foreach ($comps as $comp) + { + if (in_array($comp, array('', '.'))) + continue; + if ( + ($comp != '..') || + (!$initial_slashes && !$new_comps) || + ($new_comps && (end($new_comps) == '..')) + ) + array_push($new_comps, $comp); + elseif ($new_comps) + array_pop($new_comps); + } + $comps = $new_comps; + $path = implode('/', $comps); + if ($initial_slashes) + $path = str_repeat('/', $initial_slashes) . $path; + if ($path) + return $path; + else + return '.'; + } + + /* Similar to the os.path.join python method + * http://stackoverflow.com/a/1782990/276949 */ + public static function join() { + $args = func_get_args(); + $paths = array(); + + foreach($args as $arg) { + $paths = array_merge($paths, (array)$arg); + } + + foreach($paths as &$path) { + $path = trim($path, DIRECTORY_SEPARATOR); + } + + if (substr($args[0], 0, 1) == DIRECTORY_SEPARATOR) { + $paths[0] = DIRECTORY_SEPARATOR . $paths[0]; + } + + return join(DIRECTORY_SEPARATOR, $paths); + } +} From 6d5b6917954bb1731bd4f8bd4a86bfdb64b06ff7 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 11:44:50 -0400 Subject: [PATCH 42/62] Added config files for 2.2.0 upgrade. --- .../airtime-2.2.0/etc/airtime.conf.220 | 31 +++++ .../airtime-2.2.0/etc/api_client.cfg.220 | 119 ++++++++++++++++++ .../airtime-2.2.0/etc/media-monitor.cfg.220 | 31 +++++ .../upgrades/airtime-2.2.0/etc/pypo.cfg.220 | 85 +++++++++++++ 4 files changed, 266 insertions(+) create mode 100644 install_minimal/upgrades/airtime-2.2.0/etc/airtime.conf.220 create mode 100644 install_minimal/upgrades/airtime-2.2.0/etc/api_client.cfg.220 create mode 100644 install_minimal/upgrades/airtime-2.2.0/etc/media-monitor.cfg.220 create mode 100644 install_minimal/upgrades/airtime-2.2.0/etc/pypo.cfg.220 diff --git a/install_minimal/upgrades/airtime-2.2.0/etc/airtime.conf.220 b/install_minimal/upgrades/airtime-2.2.0/etc/airtime.conf.220 new file mode 100644 index 000000000..0853cedc9 --- /dev/null +++ b/install_minimal/upgrades/airtime-2.2.0/etc/airtime.conf.220 @@ -0,0 +1,31 @@ +[database] +host = localhost +dbname = airtime +dbuser = airtime +dbpass = airtime + +[rabbitmq] +host = 127.0.0.1 +port = 5672 +user = guest +password = guest +vhost = / + +[general] +api_key = AAA +web_server_user = www-data +airtime_dir = x +base_url = localhost +base_port = 80 + +;How many hours ahead of time should Airtime playout engine (PYPO) +;cache scheduled media files. +cache_ahead_hours = 1 + +[monit] +monit_user = guest +monit_password = airtime + +[soundcloud] +connection_retries = 3 +time_between_retries = 60 diff --git a/install_minimal/upgrades/airtime-2.2.0/etc/api_client.cfg.220 b/install_minimal/upgrades/airtime-2.2.0/etc/api_client.cfg.220 new file mode 100644 index 000000000..2e0e938e8 --- /dev/null +++ b/install_minimal/upgrades/airtime-2.2.0/etc/api_client.cfg.220 @@ -0,0 +1,119 @@ +bin_dir = "/usr/lib/airtime/api_clients" + +############################# +## Common +############################# + +# Value needed to access the API +api_key = 'AAA' + +# Path to the base of the API +api_base = 'api' + +# URL to get the version number of the server API +version_url = 'version/api_key/%%api_key%%' + +#URL to register a components IP Address with the central web server +register_component = 'register-component/format/json/api_key/%%api_key%%/component/%%component%%' + +# Hostname +base_url = 'localhost' +base_port = 80 + +############################# +## Config for Media Monitor +############################# + +# URL to setup the media monitor +media_setup_url = 'media-monitor-setup/format/json/api_key/%%api_key%%' + +# Tell Airtime the file id associated with a show instance. +upload_recorded = 'upload-recorded/format/json/api_key/%%api_key%%/fileid/%%fileid%%/showinstanceid/%%showinstanceid%%' + +# URL to tell Airtime to update file's meta data +update_media_url = 'reload-metadata/format/json/api_key/%%api_key%%/mode/%%mode%%' + +# URL to tell Airtime we want a listing of all files it knows about +list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%' + +# URL to tell Airtime we want a listing of all dirs its watching (including the stor dir) +list_all_watched_dirs = 'list-all-watched-dirs/format/json/api_key/%%api_key%%' + +# URL to tell Airtime we want to add watched directory +add_watched_dir = 'add-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%' + +# URL to tell Airtime we want to add watched directory +remove_watched_dir = 'remove-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%' + +# URL to tell Airtime we want to add watched directory +set_storage_dir = 'set-storage-dir/format/json/api_key/%%api_key%%/path/%%path%%' + +# URL to tell Airtime about file system mount change +update_fs_mount = 'update-file-system-mount/format/json/api_key/%%api_key%%' + +# URL to commit multiple updates from media monitor at the same time + +reload_metadata_group = 'reload-metadata-group/format/json/api_key/%%api_key%%' + +# URL to tell Airtime about file system mount change +handle_watched_dir_missing = 'handle-watched-dir-missing/format/json/api_key/%%api_key%%/dir/%%dir%%' + +############################# +## Config for Recorder +############################# + +# URL to get the schedule of shows set to record +show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%' + +# URL to upload the recorded show's file to Airtime +upload_file_url = 'upload-file/format/json/api_key/%%api_key%%' + +# URL to commit multiple updates from media monitor at the same time + +#number of retries to upload file if connection problem +upload_retries = 3 + +#time to wait between attempts to upload file if connection problem (in seconds) +upload_wait = 60 + +################################################################################ +# Uncomment *one of the sets* of values from the API clients below, and comment +# out all the others. +################################################################################ + +############################# +## Config for Pypo +############################# + +# Schedule export path. +# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm +# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm +export_url = 'schedule/api_key/%%api_key%%' + +get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%' + +# Update whether a schedule group has begun playing. +update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%' + +# Update whether an audio clip is currently playing. +update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%' + +# URL to tell Airtime we want to get stream setting +get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' + +#URL to update liquidsoap status +update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' + +#URL to check live stream auth +check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%' + +#URL to update source status +update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%status%%' + +get_bootstrap_info = 'get-bootstrap-info/format/json/api_key/%%api_key%%' + +get_files_without_replay_gain = 'get-files-without-replay-gain/api_key/%%api_key%%/dir_id/%%dir_id%%' + +update_replay_gain_value = 'update-replay-gain-value/api_key/%%api_key%%' + +notify_webstream_data = 'notify-webstream-data/api_key/%%api_key%%/media_id/%%media_id%%/format/json' diff --git a/install_minimal/upgrades/airtime-2.2.0/etc/media-monitor.cfg.220 b/install_minimal/upgrades/airtime-2.2.0/etc/media-monitor.cfg.220 new file mode 100644 index 000000000..b1167f56b --- /dev/null +++ b/install_minimal/upgrades/airtime-2.2.0/etc/media-monitor.cfg.220 @@ -0,0 +1,31 @@ +api_client = "airtime" + +# where the binary files live +bin_dir = '/usr/lib/airtime/media-monitor' + +# where the logging files live +log_dir = '/var/log/airtime/media-monitor' + + +############################################ +# RabbitMQ settings # +############################################ +rabbitmq_host = 'localhost' +rabbitmq_user = 'guest' +rabbitmq_password = 'guest' +rabbitmq_vhost = '/' + +############################################ +# Media-Monitor preferences # +############################################ +check_filesystem_events = 5 #how long to queue up events performed on the files themselves. +check_airtime_events = 30 #how long to queue metadata input from airtime. + +# MM2 only: +touch_interval = 5 +chunking_number = 450 +request_max_wait = 3.0 +rmq_event_wait = 0.1 +logpath = '/var/log/airtime/media-monitor/media-monitor.log' +index_path = '/var/tmp/airtime/media-monitor/last_index' + diff --git a/install_minimal/upgrades/airtime-2.2.0/etc/pypo.cfg.220 b/install_minimal/upgrades/airtime-2.2.0/etc/pypo.cfg.220 new file mode 100644 index 000000000..9ffc390e4 --- /dev/null +++ b/install_minimal/upgrades/airtime-2.2.0/etc/pypo.cfg.220 @@ -0,0 +1,85 @@ +############################################ +# pypo - configuration # +############################################ + +# Set the type of client you are using. +# Currently supported types: +# 1) "obp" = Open Broadcast Platform +# 2) "airtime" +# +api_client = "airtime" + +############################################ +# Cache Directories # +# *include* trailing slash !! # +############################################ +cache_dir = '/var/tmp/airtime/pypo/cache/' +file_dir = '/var/tmp/airtime/pypo/files/' +tmp_dir = '/var/tmp/airtime/pypo/tmp/' + +############################################ +# Setup Directories # +# Do *not* include trailing slash !! # +############################################ +cache_base_dir = '/var/tmp/airtime/pypo' +bin_dir = '/usr/lib/airtime/pypo' +log_base_dir = '/var/log/airtime' +pypo_log_dir = '/var/log/airtime/pypo' +liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap' + +############################################ +# Liquidsoap settings # +############################################ +ls_host = '127.0.0.1' +ls_port = '1234' + +############################################ +# RabbitMQ settings # +############################################ +rabbitmq_host = 'localhost' +rabbitmq_user = 'guest' +rabbitmq_password = 'guest' +rabbitmq_vhost = '/' + +############################################ +# pypo preferences # +############################################ + +# Poll interval in seconds. +# +# This will rarely need to be changed because any schedule changes are +# automatically sent to pypo immediately. +# +# This is how often the poll script downloads new schedules and files from the +# server in the event that no changes are made to the schedule. +# +poll_interval = 3600 # in seconds. + + +# Push interval in seconds. +# +# This is how often the push script checks whether it has something new to +# push to liquidsoap. +# +# It's hard to imagine a situation where this should be more than 1 second. +# +push_interval = 1 # in seconds + +# 'pre' or 'otf'. 'pre' cues while playlist preparation +# while 'otf' (on the fly) cues while loading into ls +# (needs the post_processor patch) +cue_style = 'pre' + +############################################ +# Recorded Audio settings # +############################################ +record_bitrate = 256 +record_samplerate = 44100 +record_channels = 2 +record_sample_size = 16 + +#can be either ogg|mp3, mp3 recording requires installation of the package "lame" +record_file_type = 'ogg' + +# base path to store recordered shows at +base_recorded_files = '/var/tmp/airtime/show-recorder/' From 37b7ec3e14df0e28154fcc1497183424bf035d2d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 12:12:49 -0400 Subject: [PATCH 43/62] updated sql to upgrade airtime version --- install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php b/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php index 4f30c2b8e..3ccd05606 100644 --- a/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php +++ b/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php @@ -18,7 +18,7 @@ class UpgradeCommon{ { $sql = "SELECT valstr from cc_pref WHERE keystr = 'timezone'"; - $result = self::queryDb($sql); + $result = self::queryDb($sql); $timezone = $result->fetchColumn(); date_default_timezone_set($timezone); From 8e8f1b9a5844d3139298d4a6d28b37b35502ca6d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 12:24:41 -0400 Subject: [PATCH 44/62] removed a usless check. added the project's first type annotations --- .../upgrades/airtime-2.2.0/common/UpgradeCommon.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php b/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php index 3ccd05606..199d22fe5 100644 --- a/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php +++ b/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php @@ -127,7 +127,7 @@ class UpgradeCommon{ "../etc/api_client.cfg" => self::CONF_FILE_API_CLIENT ); - echo "Copying configs:"; + echo "Copying configs:\n"; foreach ($config_copy as $path_part => $destination) { $full_path = OsPath::normpath(OsPath::join(__DIR__, "$path_part.$suffix")); @@ -139,13 +139,8 @@ class UpgradeCommon{ } } - private static function MergeConfigFiles($configFiles, $suffix) { + private static function MergeConfigFiles(array $configFiles, $suffix) { foreach ($configFiles as $conf) { - // we want to use new liquidsoap.cfg so don't merge - // also for monit - if( $conf == self::CONF_FILE_LIQUIDSOAP){ - continue; - } if (file_exists("$conf$suffix.bak")) { if($conf === self::CONF_FILE_AIRTIME) { From 462e73d93b5746de5632b4c5c458ada6bdf991e3 Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 22 Aug 2012 13:58:13 -0400 Subject: [PATCH 45/62] CC-4245: Playlists: Can only rearrange, by dragging and dropping, tracks once -fixed --- airtime_mvc/public/js/airtime/library/spl.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 7074b07b7..1d8313fe2 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -300,7 +300,7 @@ var AIRTIME = (function(AIRTIME){ .empty() .val(json.description); - $('#spl_sortable').unbind(); + $('#spl_sortable').off('focusout keydown'); $('#spl_sortable') .empty() .append(json.html); @@ -423,20 +423,20 @@ var AIRTIME = (function(AIRTIME){ //sets events dynamically for the cue editor. function setCueEvents() { var temp = $('#spl_sortable'); - temp.on("blur", ".spl_cue_in span", changeCueIn); + temp.on("focusout", ".spl_cue_in span", changeCueIn); temp.on("keydown", ".spl_cue_in span", submitOnEnter); - temp.on("blur", ".spl_cue_out span", changeCueOut); + temp.on("focusout", ".spl_cue_out span", changeCueOut); temp.on("keydown", ".spl_cue_out span", submitOnEnter); } //sets events dynamically for the fade editor. function setFadeEvents() { var temp = $('#spl_sortable'); - temp.on("blur", ".spl_fade_in span", changeFadeIn); + temp.on("focusout", ".spl_fade_in span", changeFadeIn); temp.on("keydown", ".spl_fade_in span", submitOnEnter); - temp.on("blur", ".spl_fade_out span", changeFadeOut); + temp.on("focusout", ".spl_fade_out span", changeFadeOut); temp.on("keydown", ".spl_fade_out span", submitOnEnter); } From ea4567f3734c685e1b1ee2073e6dd581eb613d35 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 22 Aug 2012 13:59:37 -0400 Subject: [PATCH 46/62] Make user functions work more consistently isHost didn't work similar to isPM or isAdmin --- .../controllers/ScheduleController.php | 8 +++---- airtime_mvc/application/models/User.php | 21 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 83ee7cf91..5494d6d0b 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -238,7 +238,7 @@ class ScheduleController extends Zend_Controller_Action } $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); - $isDJ = $user->isHost($instance->getShowId()); + $isDJ = $user->isHostOfShow($instance->getShowId()); $showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart()); $showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd()); @@ -338,7 +338,7 @@ class ScheduleController extends Zend_Controller_Action return false; } - if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) + if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER) && $user->isHostOfShow($show->getShowId()))) $show->clearShow(); } @@ -403,7 +403,7 @@ class ScheduleController extends Zend_Controller_Action return false; } - if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) { + if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER) && $user->isHostOfShow($show->getShowId()))) { $show->removeGroupFromShow($group_id); } @@ -543,7 +543,7 @@ class ScheduleController extends Zend_Controller_Action } $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); - $isDJ = $user->isHost($showInstance->getShowId()); + $isDJ = $user->isHostOfShow($showInstance->getShowId()); if (!($isAdminOrPM || $isDJ)) { return; diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index ffb137ad9..9788f7641 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -32,9 +32,17 @@ class Application_Model_User return $this->getType() == UTYPE_GUEST; } + public function isHostOfShow($showId) + { + $userId = $this->_userInstance->getDbId(); + return CcShowHostsQuery::create() + ->filterByDbShow($showId) + ->filterByDbHost($userId)->count() > 0; + } + public function isHost($showId) { - return $this->isUserType(UTYPE_HOST, $showId); + return $this->isUserType(UTYPE_HOST); } public function isPM() @@ -61,7 +69,7 @@ class Application_Model_User return $result; } - public function isUserType($type, $showId='') + public function isUserType($type) { if (is_array($type)) { $result = false; @@ -71,10 +79,7 @@ class Application_Model_User $result = $this->_userInstance->getDbType() === 'A'; break; case UTYPE_HOST: - $userId = $this->_userInstance->getDbId(); - $result = CcShowHostsQuery::create() - ->filterByDbShow($showId) - ->filterByDbHost($userId)->count() > 0; + $result = $this->_userInstance->getDbType() === 'H'; break; case UTYPE_PROGRAM_MANAGER: $result = $this->_userInstance->getDbType() === 'P'; @@ -89,9 +94,7 @@ class Application_Model_User case UTYPE_ADMIN: return $this->_userInstance->getDbType() === 'A'; case UTYPE_HOST: - $userId = $this->_userInstance->getDbId(); - - return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0; + return $this->_userInstance->getDbId() === 'H'; case UTYPE_PROGRAM_MANAGER: return $this->_userInstance->getDbType() === 'P'; } From cef3ffb07b6029cb9a0e47f585d0d0927afec242 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 22 Aug 2012 14:01:44 -0400 Subject: [PATCH 47/62] CC-4265: Keep track of how much memory each request is taking and log if over a threshold -fixed --- .../application/controllers/plugins/RabbitMqPlugin.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php b/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php index ad3042e53..c1ea6b1ba 100644 --- a/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php +++ b/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php @@ -11,5 +11,13 @@ class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract Application_Model_RabbitMq::SendMessageToShowRecorder("update_recorder_schedule"); } } + + if (memory_get_peak_usage() > 25*pow(2, 20)) { + + Logging::debug("Peak memory usage: " + .(memory_get_peak_usage()/1000000) + ." MB while accessing URI ".$_SERVER['REQUEST_URI']); + Logging::debug("Should try to keep memory footprint under 25 MB"); + } } } From 24988616b3289ce5c64571dad73f2576f87a6185 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 22 Aug 2012 14:03:11 -0400 Subject: [PATCH 48/62] CC-1665: Scheduled stream rebroadcasting and recording -current Library session object should not be stored as a property of the Controller class. -fixed --- .../controllers/LibraryController.php | 79 ++++++++++++++++--- .../controllers/PlaylistController.php | 16 ++-- 2 files changed, 76 insertions(+), 19 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index a23f2f1a7..3734b1573 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -8,7 +8,6 @@ class LibraryController extends Zend_Controller_Action { protected $obj_sess = null; - protected $search_sess = null; public function init() { @@ -23,8 +22,6 @@ class LibraryController extends Zend_Controller_Action ->addActionContext('set-num-entries', 'json') ->initContext(); - $this->obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); - $this->search_sess = new Zend_Session_Namespace("search"); } public function indexAction() @@ -59,32 +56,90 @@ class LibraryController extends Zend_Controller_Action try { - if (isset($this->obj_sess->id)) { - Logging::info($this->obj_sess->type); + $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); + //Application_Model_Library::changePlaylist(null, null); + if (isset($obj_sess->id)) { + Logging::info($obj_sess->type); $objInfo = Application_Model_Library::getObjInfo($this->obj_sess->type); - Logging::info($this->obj_sess->id); - $obj = new $objInfo['className']($this->obj_sess->id); + Logging::info($obj_sess->id); + $obj = new $objInfo['className']($obj_sess->id); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); if ($isAdminOrPM || $obj->getCreatorId() == $userInfo->id) { $this->view->obj = $obj; - if ($this->obj_sess->type == "block") { + if ($obj_sess->type == "block") { $form = new Application_Form_SmartBlockCriteria(); - $form->startForm($this->obj_sess->id); + $form->startForm($obj_sess->id); $this->view->form = $form; } } $formatter = new LengthFormatter($obj->getLength()); $this->view->length = $formatter->format(); - $this->view->type = $this->obj_sess->type; + $this->view->type = $obj_sess->type; } } catch (PlaylistNotFoundException $e) { - $this->playlistNotFound($this->obj_sess->type); + $this->playlistNotFound($obj_sess->type); } catch (Exception $e) { - $this->playlistUnknownError($e); + $this->playlistNotFound($obj_sess->type); + //$this->playlistUnknownError($e); + } + } + + private function playlistNotFound($p_type) + { + $this->view->error = "{$p_type} not found"; + + Logging::info("{$p_type} not found"); + Application_Model_Library::changePlaylist(null, $p_type); + $this->createFullResponse(null); + } + + private function playlistUnknownError($e) + { + $this->view->error = "Something went wrong."; + + Logging::info("{$e->getFile()}"); + Logging::info("{$e->getLine()}"); + Logging::info("{$e->getMessage()}"); + } + + private function createFullResponse($obj = null, $isJson = false) + { + $isBlock = false; + $viewPath = 'playlist/playlist.phtml'; + if ($obj instanceof Application_Model_Block) { + $isBlock = true; + $viewPath = 'playlist/smart-block.phtml'; + } + + if (isset($obj)) { + $formatter = new LengthFormatter($obj->getLength()); + $this->view->length = $formatter->format(); + + if ($isBlock) { + $form = new Application_Form_SmartBlockCriteria(); + $form->removeDecorator('DtDdWrapper'); + $form->startForm($obj->getId()); + + $this->view->form = $form; + $this->view->obj = $obj; + $this->view->id = $obj->getId(); + if ($isJson) { + return $this->view->render($viewPath); + } else { + $this->view->html = $this->view->render($viewPath); + } + } else { + $this->view->obj = $obj; + $this->view->id = $obj->getId(); + $this->view->html = $this->view->render($viewPath); + unset($this->view->obj); + } + } else { + $this->view->html = $this->view->render($viewPath); } } diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 8631af34c..9e3ea0380 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -2,7 +2,6 @@ class PlaylistController extends Zend_Controller_Action { - protected $obj_sess = null; public function init() { @@ -28,7 +27,6 @@ class PlaylistController extends Zend_Controller_Action ->addActionContext('get-block-info', 'json') ->initContext(); - $this->obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); } private function getPlaylist($p_type) @@ -36,8 +34,9 @@ class PlaylistController extends Zend_Controller_Action $obj = null; $objInfo = Application_Model_Library::getObjInfo($p_type); - if (isset($this->obj_sess->id)) { - $obj = new $objInfo['className']($this->obj_sess->id); + $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); + if (isset($obj_sess->id)) { + $obj = new $objInfo['className']($obj_sess->id); $modified = $this->_getParam('modified', null); if ($obj->getLastModified("U") !== $modified) { @@ -205,14 +204,17 @@ class PlaylistController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); + + $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); + try { - Logging::info("Currently active {$type} {$this->obj_sess->id}"); - if (in_array($this->obj_sess->id, $ids)) { + Logging::info("Currently active {$type} {$obj_sess->id}"); + if (in_array($obj_sess->id, $ids)) { Logging::info("Deleting currently active {$type}"); Application_Model_Library::changePlaylist(null, $type); } else { Logging::info("Not deleting currently active {$type}"); - $obj = new $objInfo['className']($this->obj_sess->id); + $obj = new $objInfo['className']($obj_sess->id); } if (strcmp($objInfo['className'], 'Application_Model_Playlist')==0) { From c8c257a3308258fc81539e126ca7d3248a748ffc Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 22 Aug 2012 14:04:01 -0400 Subject: [PATCH 49/62] CC-1665: Scheduled stream rebroadcasting and recording -change behaviour so that the webstream is not saved as soon as it it created. --- .../controllers/WebstreamController.php | 29 ++++++++++++------- airtime_mvc/application/models/Webstream.php | 4 ++- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index 5ab8213db..10944aa7b 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -16,10 +16,15 @@ class WebstreamController extends Zend_Controller_Action { $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + if (!$this->isAuthorized(-1)) { + header("Status: 401 Not Authorized"); + return; + } + $webstream = new CcWebstream(); //we're not saving this primary key in the DB so it's OK - //$webstream->setDbId(-1); + $webstream->setDbId(-1); $webstream->setDbName("Untitled Webstream"); $webstream->setDbDescription(""); $webstream->setDbUrl("http://"); @@ -28,8 +33,9 @@ class WebstreamController extends Zend_Controller_Action $webstream->setDbCreatorId($userInfo->id); $webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC'))); $webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC'))); - $webstream->save(); + //$webstream->save(); + /* $type = "stream"; $objInfo = Application_Model_Library::getObjInfo($type); @@ -39,6 +45,7 @@ class WebstreamController extends Zend_Controller_Action $type = "stream"; Application_Model_Library::changePlaylist($obj->getId(), $type); + */ $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "new"; @@ -81,7 +88,7 @@ class WebstreamController extends Zend_Controller_Action } - public function isAuthorized($id) + public function isAuthorized($webstream_id) { $hasPermission = false; $user = Application_Model_User::getCurrentUser(); @@ -89,15 +96,18 @@ class WebstreamController extends Zend_Controller_Action $hasPermission = true; } - if (!$hasPermission) { - if ($id != -1) { - $webstream = CcWebstreamQuery::create()->findPK($id); + if ($user->isHost()) { + if ($webstream_id != -1) { + $webstream = CcWebstreamQuery::create()->findPK($webstream_id); //we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission. $user = Application_Model_User::getCurrentUser(); if ($webstream->getDbCreatorId() == $user->getId()) { $hasPermission = true; } + } else { + //we are creating a new stream. Don't need to check whether the DJ/Host owns the stream + $hasPermission = true; } } @@ -108,10 +118,6 @@ class WebstreamController extends Zend_Controller_Action { $request = $this->getRequest(); - - $user = Application_Model_User::getCurrentUser(); - $hasPermission = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST)); - $id = $request->getParam("id"); $parameters = array(); @@ -131,6 +137,9 @@ class WebstreamController extends Zend_Controller_Action try { if (Application_Model_Webstream::isValid($analysis)) { $streamId = Application_Model_Webstream::save($parameters, $mime, $di); + + Application_Model_Library::changePlaylist($streamId, "stream"); + $this->view->statusMessage = "
Webstream saved.
"; $this->view->streamId = $streamId; } else { diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php index 25279686e..71c5a110a 100644 --- a/airtime_mvc/application/models/Webstream.php +++ b/airtime_mvc/application/models/Webstream.php @@ -7,9 +7,11 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable public function __construct($webstream) { //TODO: hacky... - Logging::info("x ".$webstream); if (is_int($webstream)) { $this->webstream = CcWebstreamQuery::create()->findPK($webstream); + if (is_null($this->webstream)) { + throw new Exception(); + } } else { $this->webstream = $webstream; } From ef5427d0bc33557e48c319cb5a6ea097fa1edd82 Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 22 Aug 2012 14:18:48 -0400 Subject: [PATCH 50/62] CC-4197: Media Library -> Regular Playlist: Some character get cut off in context view -fixed --- .../views/scripts/library/get-file-metadata.ajax.phtml | 6 +++--- airtime_mvc/public/css/styles.css | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml b/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml index 15aeb1bc4..7e4770332 100644 --- a/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml +++ b/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml @@ -54,11 +54,11 @@ $titleMaxStrLen) { - $row["track_title"] = substr($row["track_title"], 0, 34)."..."; + $row["track_title"] = mb_substr($row["track_title"], 0, 34, 'UTF-8')."..."; } $artistMaxStrLen = 22; - if (strlen($row["creator"]) > $artistMaxStrLen) { - $row["creator"] = substr($row["creator"], 0, 21)."..."; + if (mb_strlen($row["creator"], 'UTF-8') > $artistMaxStrLen) { + $row["creator"] = mb_substr($row["creator"], 0, 21, 'UTF-8')."..."; } ?> Date: Wed, 22 Aug 2012 14:38:48 -0400 Subject: [PATCH 51/62] cleaned up ApiController.php a little bit. --- .../application/controllers/ApiController.php | 32 ++++++++----------- .../airtime-2.2.0/common/UpgradeCommon.php | 6 ++-- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index fee9d32c5..353325948 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -547,26 +547,24 @@ class ApiController extends Zend_Controller_Action public function reloadMetadataGroupAction() { - $request = $this->getRequest(); // extract all file metadata params from the request. // The value is a json encoded hash that has all the information related to this action // The key(mdXXX) does not have any meaning as of yet but it could potentially correspond // to some unique id. - $responses = array(); - $dry = $request->getParam('dry') || false; - $params = $request->getParams(); + $request = $this->getRequest(); + $responses = array(); + $dry = $request->getParam('dry') || false; + $params = $request->getParams(); $valid_modes = array('delete_dir', 'delete', 'moved', 'modify', 'create'); foreach ($request->getParams() as $k => $raw_json) { - // Valid requests must start with mdXXX where XXX represents at least 1 digit + // Valid requests must start with mdXXX where XXX represents at + // least 1 digit if( !preg_match('/^md\d+$/', $k) ) { continue; } - $info_json = json_decode($raw_json, $assoc=true); - $recorded = $info_json["is_record"]; + $info_json = json_decode($raw_json, $assoc = true); + $recorded = $info_json["is_record"]; unset( $info_json["is_record"] ); - //unset( $info_json["MDATA_KEY_DURATION"] ); - //unset( $info_json["MDATA_KEY_SAMPLERATE"] ); - //unset( $info_json["MDATA_KEY_BITRATE"] ); - - if( !array_key_exists('mode', $info_json) ) { // Log invalid requests + // Log invalid requests + if( !array_key_exists('mode', $info_json) ) { Logging::info("Received bad request(key=$k), no 'mode' parameter. Bad request is:"); Logging::info( $info_json ); array_push( $responses, array( @@ -574,8 +572,8 @@ class ApiController extends Zend_Controller_Action 'key' => $k)); continue; } elseif ( !in_array($info_json['mode'], $valid_modes) ) { - // A request still has a chance of being invalid even if it exists but it's validated - // by $valid_modes array + // A request still has a chance of being invalid even if it + // exists but it's validated by $valid_modes array $mode = $info_json['mode']; Logging::info("Received bad request(key=$k). 'mode' parameter was invalid with value: '$mode'. Request:"); Logging::info( $info_json ); @@ -588,14 +586,12 @@ class ApiController extends Zend_Controller_Action // Removing 'mode' key from $info_json might not be necessary... $mode = $info_json['mode']; unset( $info_json['mode'] ); - $response = $this->dispatchMetadata($info_json, $mode, $dry_run=$dry); + $response = $this->dispatchMetadata($info_json, $mode, + $dry_run=$dry); // We tack on the 'key' back to every request in case the would like to associate // his requests with particular responses $response['key'] = $k; array_push($responses, $response); - // On recorded show requests we do some extra work here. Not sure what it actually is and it - // was usually called from the python api client. Now we just call it straight from the controller to - // save the http roundtrip } die( json_encode($responses) ); } diff --git a/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php b/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php index 199d22fe5..9942945da 100644 --- a/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php +++ b/install_minimal/upgrades/airtime-2.2.0/common/UpgradeCommon.php @@ -95,7 +95,7 @@ class UpgradeCommon{ // Backup the config files $suffix = date("Ymdhis")."-".UpgradeCommon::VERSION_NUMBER; foreach ($configFiles as $conf) { - // do not back up monit cfg + // do not back up monit cfg -- ok?? not being done anyway if (file_exists($conf)) { echo "Backing up $conf to $conf$suffix.bak".PHP_EOL; //copy($conf, $conf.$suffix.".bak"); @@ -210,11 +210,11 @@ class UpgradeCommon{ private static function UpdateIniValue($p_filename, $p_property, $p_value) { $lines = file($p_filename); - $n=count($lines); + $n = count($lines); foreach ($lines as &$line) { if ($line[0] != "#"){ $key_value = explode("=", $line); - $key = trim($key_value[0]); + $key = trim($key_value[0]); if ($key == $p_property){ $line = "$p_property = $p_value".PHP_EOL; From d12b1645fd29351543ef7e790eed62997979f2a8 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 14:39:25 -0400 Subject: [PATCH 52/62] MM2: Fixed bug where mm would choke on songs without MDATA_KEY_CREATOR when trying to decide if they are recorded or not. --- python_apps/media-monitor2/media/monitor/pure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index 89c859ace..fa4aa7480 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -83,6 +83,7 @@ def is_file_supported(path): # TODO : In the future we would like a better way to find out whether a show # has been recorded def is_airtime_recorded(md): + if not 'MDATA_KEY_CREATOR' in md: return False return md['MDATA_KEY_CREATOR'] == u'Airtime Show Recorder' def clean_empty_dirs(path): From 0071caf94deccb823b6868f51860491ff1d821e4 Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 22 Aug 2012 15:22:01 -0400 Subject: [PATCH 53/62] CC-4080: Calendar -> Cannot create show because there was a repeating show at same time before -fixed --- airtime_mvc/application/models/Schedule.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index f5f4ee501..43986c2e8 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1065,10 +1065,11 @@ SQL; if ($update) { $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." where ends <= '{$show_end->format('Y-m-d H:i:s')}' - and id != ".$instanceId. " order by ends"; + and modified_instance = false and id != ".$instanceId. " order by ends"; } else { $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." - where ends <= '{$show_end->format('Y-m-d H:i:s')}' order by ends"; + where ends <= '{$show_end->format('Y-m-d H:i:s')}' + and modified_instance = false order by ends"; } $rows = $con->query($sql); From 91f13a62796267be7a95f2a3a6ab12828fcb40ec Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 22 Aug 2012 15:34:59 -0400 Subject: [PATCH 54/62] CC-1665: Scheduled stream rebroadcasting and recording -current Library session object should not be stored as a property of the Controller class. -fixed --- .../controllers/LibraryController.php | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 3734b1573..4cf664a09 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -7,8 +7,6 @@ require_once 'formatters/BitrateFormatter.php'; class LibraryController extends Zend_Controller_Action { - protected $obj_sess = null; - public function init() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); @@ -88,7 +86,7 @@ class LibraryController extends Zend_Controller_Action } } - private function playlistNotFound($p_type) + protected function playlistNotFound($p_type) { $this->view->error = "{$p_type} not found"; @@ -97,7 +95,7 @@ class LibraryController extends Zend_Controller_Action $this->createFullResponse(null); } - private function playlistUnknownError($e) + protected function playlistUnknownError($e) { $this->view->error = "Something went wrong."; @@ -106,7 +104,7 @@ class LibraryController extends Zend_Controller_Action Logging::info("{$e->getMessage()}"); } - private function createFullResponse($obj = null, $isJson = false) + protected function createFullResponse($obj = null, $isJson = false) { $isBlock = false; $viewPath = 'playlist/playlist.phtml'; @@ -166,17 +164,18 @@ class LibraryController extends Zend_Controller_Action $file = Application_Model_StoredFile::Recall($id); - if (isset($this->obj_sess->id) && $screen == "playlist") { + $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); + if (isset($obj_sess->id) && $screen == "playlist") { // if the user is not admin or pm, check the creator and see if this person owns the playlist or Block - if ($this->obj_sess->type == 'playlist') { - $obj = new Application_Model_Playlist($this->obj_sess->id); + if ($obj_sess->type == 'playlist') { + $obj = new Application_Model_Playlist($obj_sess->id); } else { - $obj = new Application_Model_Block($this->obj_sess->id); + $obj = new Application_Model_Block($obj_sess->id); } if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) { - if ($this->obj_sess->type === "playlist") { + if ($obj_sess->type === "playlist") { $menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy"); - } else if ($this->obj_sess->type === "block") { + } else if ($obj_sess->type === "block") { $menu["pl_add"] = array("name"=> "Add to Smart Block", "icon" => "add-playlist", "icon" => "copy"); } } @@ -197,13 +196,13 @@ class LibraryController extends Zend_Controller_Action unset($menu["play"]); } if (($isAdminOrPM || $obj->getCreatorId() == $user->getId()) && $screen == "playlist") { - if ($this->obj_sess->type === "playlist") { + if ($obj_sess->type === "playlist") { $menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy"); } } } - if ($this->obj_sess->id !== $id && $screen == "playlist") { + if ($obj_sess->id !== $id && $screen == "playlist") { if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) { $menu["edit"] = array("name"=> "Edit", "icon" => "edit"); } @@ -215,9 +214,9 @@ class LibraryController extends Zend_Controller_Action $webstream = CcWebstreamQuery::create()->findPK($id); $obj = new Application_Model_Webstream($webstream); - if (isset($this->obj_sess->id) && $screen == "playlist") { + if (isset($obj_sess->id) && $screen == "playlist") { if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) { - if ($this->obj_sess->type === "playlist") { + if ($obj_sess->type === "playlist") { $menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy"); } } From fe1aa7a169d618bfce9de00784cca3a18e342f8e Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 22 Aug 2012 15:56:18 -0400 Subject: [PATCH 55/62] CC-1665: Scheduled stream rebroadcasting and recording -fixed syntax error --- airtime_mvc/application/controllers/LibraryController.php | 6 +++--- airtime_mvc/application/models/Library.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 4cf664a09..c29904974 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -55,11 +55,10 @@ class LibraryController extends Zend_Controller_Action try { $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); - //Application_Model_Library::changePlaylist(null, null); if (isset($obj_sess->id)) { - Logging::info($obj_sess->type); - $objInfo = Application_Model_Library::getObjInfo($this->obj_sess->type); Logging::info($obj_sess->id); + Logging::info($obj_sess->type); + $objInfo = Application_Model_Library::getObjInfo($obj_sess->type); $obj = new $objInfo['className']($obj_sess->id); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -82,6 +81,7 @@ class LibraryController extends Zend_Controller_Action $this->playlistNotFound($obj_sess->type); } catch (Exception $e) { $this->playlistNotFound($obj_sess->type); + Logging::info($e->getMessage()); //$this->playlistUnknownError($e); } } diff --git a/airtime_mvc/application/models/Library.php b/airtime_mvc/application/models/Library.php index 27e22400f..4245fa47f 100644 --- a/airtime_mvc/application/models/Library.php +++ b/airtime_mvc/application/models/Library.php @@ -13,6 +13,8 @@ class Application_Model_Library $info['className'] = 'Application_Model_Block'; } else if (strcmp($p_type, 'stream')==0) { $info['className'] = 'Application_Model_Webstream'; + } else { + throw new Exception("Unknown object type: '$p_type'"); } return $info; @@ -21,7 +23,6 @@ class Application_Model_Library public static function changePlaylist($p_id, $p_type) { $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); - Logging::info($obj_sess); if (is_null($p_id) || is_null($p_type)) { unset($obj_sess->id); From 7e50a11195e1fe69f10e21ecff5e9b08c56a76c1 Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 22 Aug 2012 16:01:50 -0400 Subject: [PATCH 56/62] CC-4225: Smart playlists: Sample and bit rate ranges should include entered values -fixed --- airtime_mvc/application/forms/SmartBlockCriteria.php | 4 ++-- airtime_mvc/application/models/Block.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/forms/SmartBlockCriteria.php b/airtime_mvc/application/forms/SmartBlockCriteria.php index 0e68f957a..8d2e9683d 100644 --- a/airtime_mvc/application/forms/SmartBlockCriteria.php +++ b/airtime_mvc/application/forms/SmartBlockCriteria.php @@ -4,7 +4,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm private $criteriaOptions = array( 0 => "Select criteria", "album_title" => "Album", - "bit_rate" => "Bit Rate", + "bit_rate" => "Bit Rate (Kbps)", "bpm" => "Bpm", "comments" => "Comments", "composer" => "Composer", @@ -23,7 +23,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm "name" => "Name", "orchestra" => "Orchestra", "rating" => "Rating", - "sample_rate" => "Sample Rate", + "sample_rate" => "Sample Rate (kHz)", "track_title" => "Title", "track_number" => "Track Number", "utime" => "Uploaded", diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index ea4b71d92..a7b39869e 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -1162,7 +1162,7 @@ EOT; $spCriteria = 'date('.$spCriteria.')'; $spCriteriaValue = substr($spCriteriaValue, 0, 10); } - } else if($spCriteria == "bit_rate") { + } else if($spCriteria == "bit_rate" || $spCriteria == 'sample_rate') { // multiply 1000 because we store only number value // e.g 192kps is stored as 192000 $spCriteriaValue = $criteria['value']*1000; @@ -1177,7 +1177,7 @@ EOT; } else if ($spCriteriaModifier == "contains" || $spCriteriaModifier == "does not contain") { $spCriteriaValue = "%$spCriteriaValue%"; } else if ($spCriteriaModifier == "is in the range") { - $spCriteriaValue = "$spCriteria > '$spCriteriaValue' AND $spCriteria <= '$criteria[extra]'"; + $spCriteriaValue = "$spCriteria >= '$spCriteriaValue' AND $spCriteria <= '$criteria[extra]'"; } $spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier]; From d1e734104605c29a5724e313e455e755ab87e385 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 16:08:46 -0400 Subject: [PATCH 57/62] cc-3936: Refactored php code to upload files --- airtime_mvc/application/models/StoredFile.php | 89 +++++++++---------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 642212fc5..9be0e51b0 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -853,58 +853,55 @@ class Application_Model_StoredFile { $audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $tempname; Logging::info('copyFileToStor: moving file '.$audio_file); - $md5 = md5_file($audio_file); - $duplicate = Application_Model_StoredFile::RecallByMd5($md5, true); - $result = null; - if ($duplicate) { - if (file_exists($duplicate->getFilePath())) { - $duplicateName = $duplicate->getMetadataValue('MDATA_KEY_TITLE'); - $result = array( "code" => 106, "message" => "An identical audioclip named '$duplicateName' already exists on the server."); + $storDir = Application_Model_MusicDir::getStorDir(); + $stor = $storDir->getDirectory(); + // check if "organize" dir exists and if not create one + if (!file_exists($stor."/organize")) { + if (!mkdir($stor."/organize", 0777)) { + return array( + "code" => 109, + "message" => "Failed to create 'organize' directory."); } } - if (!isset($result)) {//The file has no duplicate, so proceed to copy. - $storDir = Application_Model_MusicDir::getStorDir(); - $stor = $storDir->getDirectory(); - // check if "organize" dir exists and if not create one - if (!file_exists($stor."/organize")) { - if (!mkdir($stor."/organize", 0777)) { - $result = array("code" => 109, "message" => "Failed to create 'organize' directory."); - - return $result; - } - } - - if (chmod($audio_file, 0644) === false) { - Logging::info("Warning: couldn't change permissions of $audio_file to 0644"); - } - - //check to see if there is enough space in $stor to continue. - if (self::isEnoughDiskSpaceToCopy($stor, $audio_file)) { - $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName); - - if (self::liquidsoapFilePlayabilityTest($audio_file)) { - - Logging::info("copyFileToStor: moving file $audio_file to $audio_stor"); - - //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation - if (@rename($audio_file, $audio_stor) === false) { - #something went wrong likely there wasn't enough space in the audio_stor to move the file too. - #warn the user that the file wasn't uploaded and they should check if there is enough disk space. - unlink($audio_file);//remove the file after failed rename - $result = array("code" => 108, "message" => "The file was not uploaded, this error can occur if the computer hard drive does not have enough disk space or the stor directory does not have correct write permissions."); - } - } else { - $result = array("code" => 110, "message" => "This file appears to be corrupted and will not be added to media library."); - } - - } else { - $result = array("code" => 107, "message" => "The file was not uploaded, there is ".$freeSpace."MB of disk space left and the file you are uploading has a size of ".$fileSize."MB."); - } + if (chmod($audio_file, 0644) === false) { + Logging::info("Warning: couldn't change permissions of $audio_file to 0644"); } - return $result; + // Check if we have enough space before copying + if(!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) { + $freeSpace = disk_free_space($stor); + return array("code" => 107, + "message" => "The file was not uploaded, there is + ".$freeSpace."MB of disk space left and the file you are + uploading has a size of ".$fileSize."MB."); + } + + // Check if liquidsoap can play this file + if(!self::liquidsoapFilePlayabilityTest($audio_file)) { + return array( + "code" => 110, + "message" => "This file appears to be corrupted and will not + be added to media library."); + } + + // Did all the checks for realz, now trying to copy + $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName); + Logging::info("copyFileToStor: moving file $audio_file to $audio_stor"); + //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation + if (@rename($audio_file, $audio_stor) === false) { + #something went wrong likely there wasn't enough space in the audio_stor to move the file too. + #warn the user that the file wasn't uploaded and they should check if there is enough disk space. + unlink($audio_file);//remove the file after failed rename + return array( + "code" => 108, + "message" => " + The file was not uploaded, this error can occur if the computer + hard drive does not have enough disk space or the stor + directory does not have correct write permissions. "); + } + return null; } /* From 442c156458f9fff7aad617acfc756dac3680f06f Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 22 Aug 2012 16:08:51 -0400 Subject: [PATCH 58/62] CC-1665: Scheduled stream rebroadcasting and recording -fixed context menu for webstreams --- .../application/controllers/LibraryController.php | 9 +++++---- .../application/controllers/WebstreamController.php | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index c29904974..e647f4b30 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -160,16 +160,17 @@ class LibraryController extends Zend_Controller_Action $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); + $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); + if ($type === "audioclip") { $file = Application_Model_StoredFile::Recall($id); - $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); if (isset($obj_sess->id) && $screen == "playlist") { // if the user is not admin or pm, check the creator and see if this person owns the playlist or Block if ($obj_sess->type == 'playlist') { $obj = new Application_Model_Playlist($obj_sess->id); - } else { + } else if ($obj_sess->type == 'block') { $obj = new Application_Model_Block($obj_sess->id); } if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) { @@ -187,10 +188,10 @@ class LibraryController extends Zend_Controller_Action $url = $file->getRelativeFileUrl($baseUrl).'/download/true'; $menu["download"] = array("name" => "Download", "icon" => "download", "url" => $url); - } elseif ($type === "playlist" || $type === "block") { + } else if ($type === "playlist" || $type === "block") { if ($type === 'playlist') { $obj = new Application_Model_Playlist($id); - } else { + } else if ($type === 'block') { $obj = new Application_Model_Block($id); if (!$obj->isStatic()) { unset($menu["play"]); diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index 10944aa7b..670fc859a 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -46,6 +46,8 @@ class WebstreamController extends Zend_Controller_Action $type = "stream"; Application_Model_Library::changePlaylist($obj->getId(), $type); */ + //clear the session in case an old playlist was open: CC-4196 + Application_Model_Library::changePlaylist(null, null); $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "new"; @@ -61,7 +63,11 @@ class WebstreamController extends Zend_Controller_Action throw new Exception("Missing parameter 'id'"); } + $webstream = CcWebstreamQuery::create()->findPK($id); + if ($webstream) { + Application_Model_Library::changePlaylist($id, "stream"); + } $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "edit"; $this->view->html = $this->view->render('webstream/webstream.phtml'); From f47e32d9de58ff232790f966a1feed0e1d9fef9a Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 22 Aug 2012 16:29:17 -0400 Subject: [PATCH 59/62] CC-4266: Smart Block: Bit rate with 'is in the range' modifier -> 2nd range value doesn't get multiplied by 1000 -fixed --- airtime_mvc/application/models/Block.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index a7b39869e..2b88568fa 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -1166,6 +1166,9 @@ EOT; // multiply 1000 because we store only number value // e.g 192kps is stored as 192000 $spCriteriaValue = $criteria['value']*1000; + if (isset($criteria['extra'])) { + $criteria['extra'] *= 1000; + } } else { $spCriteriaValue = addslashes($criteria['value']); } From c7cf687e66dc11baedeef1c299aa415df7f24d2e Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 17:01:39 -0400 Subject: [PATCH 60/62] MM2: Imporoved some logging and error checking. --- python_apps/media-monitor2/media/monitor/eventcontractor.py | 3 +++ python_apps/media-monitor2/media/monitor/metadata.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/python_apps/media-monitor2/media/monitor/eventcontractor.py b/python_apps/media-monitor2/media/monitor/eventcontractor.py index 9eb181bf4..089b30a44 100644 --- a/python_apps/media-monitor2/media/monitor/eventcontractor.py +++ b/python_apps/media-monitor2/media/monitor/eventcontractor.py @@ -57,4 +57,7 @@ class EventContractor(Loggable): def __unregister(self, evt): try: del self.store[evt.path] + except KeyError as e: + self.logger.info("Contractor failed to unrecord event: '%s'" \ + % evt.path) except Exception as e: self.unexpected_exception(e) diff --git a/python_apps/media-monitor2/media/monitor/metadata.py b/python_apps/media-monitor2/media/monitor/metadata.py index 5f222c4b4..f718b7b2e 100644 --- a/python_apps/media-monitor2/media/monitor/metadata.py +++ b/python_apps/media-monitor2/media/monitor/metadata.py @@ -154,6 +154,11 @@ class Metadata(Loggable): try : full_mutagen = mutagen.File(fpath, easy=True) except Exception : raise BadSongFile(fpath) self.path = fpath + if not os.path.exists(self.path): + self.logger.info("Attempting to read metadata of file \ + that does not exist. Setting metadata to {}") + self.__metadata = {} + return # TODO : Simplify the way all of these rules are handled right not it's # extremely unclear and needs to be refactored. self.__metadata = Metadata.airtime_dict(full_mutagen) From 5d40bd851d702f1d7bb15c0c35e9b40501e3b5b6 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 22 Aug 2012 17:25:19 -0400 Subject: [PATCH 61/62] added upgrade.sql for 2.2.0 upgrade --- install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql diff --git a/install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql b/install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql new file mode 100644 index 000000000..b4fffb97f --- /dev/null +++ b/install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql @@ -0,0 +1,2 @@ +DELETE FROM cc_pref WHERE keystr = 'system_version'; +INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.2.0'); From 38173bd3a2a13828ca43911fdd505ea3de723614 Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 23 Aug 2012 10:19:00 -0400 Subject: [PATCH 62/62] - small fix --- airtime_mvc/application/controllers/LibraryController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index e647f4b30..32db3e06b 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -56,6 +56,7 @@ class LibraryController extends Zend_Controller_Action $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); if (isset($obj_sess->id)) { + $objInfo = Application_Model_Library::getObjInfo($obj_sess->type); Logging::info($obj_sess->id); Logging::info($obj_sess->type); $objInfo = Application_Model_Library::getObjInfo($obj_sess->type);