diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 8bcec1d4c..adffb8616 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -78,7 +78,7 @@ class ApiController extends Zend_Controller_Action if (ctype_alnum($file_id) && strlen($file_id) == 32) { $media = StoredFile::RecallByGunid($file_id); if ($media != null && !PEAR::isError($media)) { - $filepath = $media->getRealFilePath(); + $filepath = $media->getFilePath(); if(!is_file($filepath)) { header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); @@ -419,7 +419,7 @@ class ApiController extends Zend_Controller_Action //New file added to Airtime if (is_null($file)) { - $file = new StoredFile($md); + $file = StoredFile::Insert($md); } //Updating a metadata change. else { diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 180402d7c..7af715338 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -78,7 +78,7 @@ class LibraryController extends Zend_Controller_Action $file_id = $this->_getParam('id', null); $file = StoredFile::Recall($file_id); - $url = $file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; + $url = $file->getFileUrl().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), 'title' => 'Download'); @@ -162,10 +162,10 @@ class LibraryController extends Zend_Controller_Action if ($form->isValid($request->getPost())) { $formdata = $form->getValues(); - $file->replaceDbMetadata($formdata); + $file->setDbColMetadata($formdata); $data = $formdata; - $data['filepath'] = $file->getRealFilePath(); + $data['filepath'] = $file->getFilePath(); //wait for 1.9.0 release //RabbitMq::SendFileMetaData($data); @@ -173,7 +173,7 @@ class LibraryController extends Zend_Controller_Action } } - $form->populate($file->md); + $form->populate($file->getDbColMetadata()); $this->view->form = $form; } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 7e2102677..acde9dae5 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -43,13 +43,9 @@ class StoredFile { "md5" => "DbMd5" ); - public function __construct($md) + public function __construct() { - $this->_file = new CcFiles(); - $this->_file->setDbGunid(md5(uniqid("", true))); - $this->_file->save(); - $this->setMetadata($md); } public function getId() @@ -57,6 +53,10 @@ class StoredFile { return $this->_file->getDbId(); } + public function getGunId() { + return $this->_file->getDbGunid(); + } + public function getFormat() { return $this->_file->getDbFtype(); @@ -380,7 +380,30 @@ class StoredFile { public function getFileUrl() { global $CC_CONFIG; - return "http://$CC_CONFIG[baseUrl]:$CC_CONFIG[basePort]/api/get-media/file/".$this->gunid.".".$this->getFileExtension(); + return "http://$CC_CONFIG[baseUrl]:$CC_CONFIG[basePort]/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); + } + + public static function Insert($md=null) + { + $file = new CcFiles(); + $file->setDbGunid(md5(uniqid("", true))); + $file->save(); + + if(isset($md)) { + if (preg_match("/mp3/i", $md['MDATA_KEY_MIME'])) { + $file->setDbFtype("audioclip"); + } + else if (preg_match("/vorbis/i", $md['MDATA_KEY_MIME'])) { + $file->setDbFtype("audioclip"); + } + + $this->setMetadata($md); + } + + $storedFile = new StoredFile(); + $storedFile->_file = $file; + + return $storedFile; } /** @@ -394,26 +417,26 @@ class StoredFile { * global unique id of file * @param string $p_md5sum * MD5 sum of the file - * @return StoredFile|Playlist|NULL + * @return StoredFile|NULL * Return NULL if the object doesnt exist in the DB. */ public static function Recall($p_id=null, $p_gunid=null, $p_md5sum=null, $p_filepath=null) { if (isset($p_id)) { - $storedFile = CcFilesQuery::create()->findPK(intval($p_id)); + $file = CcFilesQuery::create()->findPK(intval($p_id)); } else if (isset($p_gunid)) { - $storedFile = CcFilesQuery::create() + $file = CcFilesQuery::create() ->filterByDbGunid($p_gunid) ->findOne(); } else if (isset($p_md5sum)) { - $storedFile = CcFilesQuery::create() + $file = CcFilesQuery::create() ->filterByDbMd5($p_md5sum) ->findOne(); } else if (isset($p_filepath)) { - $storedFile = CcFilesQuery::create() + $file = CcFilesQuery::create() ->filterByDbFilepath($p_filepath) ->findOne(); } @@ -421,6 +444,9 @@ class StoredFile { return null; } + $storedFile = new StoredFile(); + $storedFile->_file = $file; + return $storedFile; } diff --git a/python_apps/media-monitor/MediaMonitor.py b/python_apps/media-monitor/MediaMonitor.py index 5a7e07a83..7fa9d5ee5 100644 --- a/python_apps/media-monitor/MediaMonitor.py +++ b/python_apps/media-monitor/MediaMonitor.py @@ -275,6 +275,8 @@ class MediaMonitor(ProcessEvent): else : return False + def setUpMediaMonitor(self, event): + pass def process_IN_CREATE(self, event): if not event.dir: