From 1f9a39f22d9cfa13d438da4ed4ff31d74063d57e Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Thu, 9 Jun 2011 10:28:56 +0200 Subject: [PATCH] CC-1799Put Airtime Storage into a Human Readable File Naming Convention new API method to check media status. --- .../application/controllers/ApiController.php | 19 ++++++++++++++++ python_apps/api_clients/api_client.py | 22 +++++++++++++++++++ python_apps/media-monitor/MediaMonitor.py | 4 +++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index a545aaa20..8bcec1d4c 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -354,6 +354,25 @@ class ApiController extends Zend_Controller_Action $this->view->id = $file->getId(); } + public function mediaMonitorSetupAction() { + global $CC_CONFIG; + + // disable the view and the layout + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + $api_key = $this->_getParam('api_key'); + if (!in_array($api_key, $CC_CONFIG["apiKey"])) + { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + exit; + } + + $this->view->stor = $CC_CONFIG['storageDir']; + $this->view->plupload = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload"; + } + public function mediaItemStatusAction() { global $CC_CONFIG; diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 84e1a4d43..a0381a99e 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -117,6 +117,9 @@ class ApiClientInterface: def upload_recorded_show(self): pass + def check_media_status(self, md5): + pass + def update_media_metadata(self, md): pass @@ -356,6 +359,25 @@ class AirTimeApiClient(ApiClientInterface): return response + def check_media_status(self, md5): + logger = logging.getLogger() + + response = None + try: + url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["media_status_url"]) + url = url.replace("%%api_key%%", self.config["api_key"]) + url = url.replace("%%md5%%", md5) + logger.debug(url) + + response = urllib.urlopen(url) + response = json.loads(response.read()) + logger.info("Json Media Status %s", response) + + except Exception, e: + logger.error("Exception: %s", e) + + return response + def update_media_metadata(self, md): logger = logging.getLogger() response = None diff --git a/python_apps/media-monitor/MediaMonitor.py b/python_apps/media-monitor/MediaMonitor.py index 3b5899f31..5a7e07a83 100644 --- a/python_apps/media-monitor/MediaMonitor.py +++ b/python_apps/media-monitor/MediaMonitor.py @@ -332,7 +332,9 @@ if __name__ == '__main__': logger = logging.getLogger('root') logger.info("Added watch to %s", storage_directory) - notifier = AirtimeNotifier(wm, MediaMonitor(), read_freq=int(config["check_filesystem_events"]), timeout=1) + mm = MediaMonitor() + + notifier = AirtimeNotifier(wm, mm, read_freq=int(config["check_filesystem_events"]), timeout=1) notifier.coalesce_events() notifier.loop(callback=checkRabbitMQ) except KeyboardInterrupt: