From 4f576afc003488eb87fd2b785bc1afdad9c4b8f1 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 15:24:02 -0400 Subject: [PATCH] cc-4396. Initial fix problem was a module was not being included in the soundcloud upload script. --- .../application/controllers/ApiController.php | 15 ++++++++------- .../application/controllers/LibraryController.php | 2 +- .../controllers/ScheduleController.php | 3 ++- airtime_mvc/application/models/Soundcloud.php | 8 +++++++- utils/soundcloud-uploader.php | 1 + 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 033369802..a0918d60d 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -415,8 +415,9 @@ class ApiController extends Zend_Controller_Action $this->uploadRecordedActionParam($show_instance_id, $file_id); } - // The paramterized version of the uploadRecordedAction controller. We want this controller's action - // to be invokable from other controllers instead being of only through http + // The paramterized version of the uploadRecordedAction controller. + // We want this controller's action to be invokable from other + // controllers instead being of only through http public function uploadRecordedActionParam($show_instance_id, $file_id) { $showCanceled = false; @@ -430,10 +431,10 @@ class ApiController extends Zend_Controller_Action } catch (Exception $e) { //we've reached here probably because the show was - //cancelled, and therefore the show instance does not - //exist anymore (ShowInstance constructor threw this error). - //We've done all we can do (upload the file and put it in - //the library), now lets just return. + //cancelled, and therefore the show instance does not exist + //anymore (ShowInstance constructor threw this error). We've + //done all we can do (upload the file and put it in the + //library), now lets just return. $showCanceled = true; } @@ -444,7 +445,7 @@ class ApiController extends Zend_Controller_Action if (!$showCanceled && Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud()) { $id = $file->getId(); - $res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + Application_Model_Soundcloud::uploadSoundcloud($id); } } diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index fa6a92e68..2d8f06b71 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -469,7 +469,7 @@ class LibraryController extends Zend_Controller_Action public function uploadFileSoundcloudAction() { $id = $this->_getParam('id'); - $res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + Application_Model_Soundcloud::uploadSoundcloud($id); // we should die with ui info die(); } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index f65ce1332..c2fe93dbb 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -217,7 +217,8 @@ class ScheduleController extends Zend_Controller_Action $file = $show_inst->getRecordedFile(); $id = $file->getId(); - $res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + //$res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + Application_Model_Soundcloud::uploadSoundcloud($id); // we should die with ui info die(); } diff --git a/airtime_mvc/application/models/Soundcloud.php b/airtime_mvc/application/models/Soundcloud.php index 7e2b74d57..4dd99444a 100644 --- a/airtime_mvc/application/models/Soundcloud.php +++ b/airtime_mvc/application/models/Soundcloud.php @@ -52,7 +52,6 @@ class Application_Model_Soundcloud //YYYY-MM-DD-HH-mm-SS $release = explode("-", $release); - $track_data['track[release_year]'] = $release[0]; $track_data['track[release_month]'] = $release[1]; $track_data['track[release_day]'] = $release[2]; @@ -87,6 +86,13 @@ class Application_Model_Soundcloud throw new NoSoundCloundToken(); } } + + public static function uploadSoundcloud($id) + { + $cmd = "/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"; + Logging::info("Uploading soundcloud with command: $cmd"); + exec($cmd); + } } class NoSoundCloundToken extends Exception {} diff --git a/utils/soundcloud-uploader.php b/utils/soundcloud-uploader.php index ea6826aab..2660d32e2 100644 --- a/utils/soundcloud-uploader.php +++ b/utils/soundcloud-uploader.php @@ -33,6 +33,7 @@ set_include_path(implode(PATH_SEPARATOR, array( require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php'); require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php'); require_once($CC_CONFIG['phpDir'].'/application/models/MusicDir.php'); +require_once($CC_CONFIG['phpDir'].'/application/common/OsPath.php'); set_include_path($CC_CONFIG['phpDir'].'/library' . PATH_SEPARATOR . get_include_path()); require_once($CC_CONFIG['phpDir'].'/application/models/Soundcloud.php');