diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 9911b8931..d9ffceae0 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -14,6 +14,7 @@ require_once (__DIR__."/configs/constants.php"); require_once (__DIR__."/configs/conf.php"); require_once 'DB.php'; +require_once 'Soundcloud.php'; require_once 'Playlist.php'; require_once 'StoredFile.php'; require_once 'Schedule.php'; diff --git a/application/configs/conf.php b/application/configs/conf.php index f43dde788..c1e98d0bb 100644 --- a/application/configs/conf.php +++ b/application/configs/conf.php @@ -46,6 +46,9 @@ $CC_CONFIG = array( 'apiKey' => $values['api_key'], 'apiPath' => '/api/', + 'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A', + 'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs', + "rootDir" => __DIR__."/../..", 'pearPath' => dirname(__FILE__).'/../../library/pear', 'zendPath' => dirname(__FILE__).'/../../library/Zend', diff --git a/application/controllers/PluploadController.php b/application/controllers/PluploadController.php index aae777f23..25dc47482 100644 --- a/application/controllers/PluploadController.php +++ b/application/controllers/PluploadController.php @@ -167,7 +167,12 @@ class PluploadController extends Zend_Controller_Action $upload_dir = ini_get("upload_tmp_dir"); $file = $this->upload($upload_dir); - //$file->getRealFilePath(); + if(Application_Model_Preference::GetDoSoundCloudUpload()) + { + $soundcloud = new ATSoundcloud(); + $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName()); + } + die('{"jsonrpc" : "2.0", "id" : '.$file->getId().' }'); } diff --git a/application/forms/Preferences.php b/application/forms/Preferences.php index 594882f6f..5af7c6a44 100644 --- a/application/forms/Preferences.php +++ b/application/forms/Preferences.php @@ -17,7 +17,7 @@ class Application_Form_Preferences extends Zend_Form 'value' => Application_Model_Preference::GetValue("station_name") )); - $defaultFade = Application_Model_Preference::GetValue("default_fade"); + $defaultFade = Application_Model_Preference::GetDefaultFade(); if($defaultFade == ""){ $defaultFade = '00:00:00.000000'; } @@ -46,7 +46,7 @@ class Application_Form_Preferences extends Zend_Form $this->addElement('checkbox', 'UseSoundCloud', array( 'label' => 'Automatically Upload Recorded Shows To SoundCloud', 'required' => false, - 'value' => Application_Model_Preference::GetValue("soundcloud_upload") + 'value' => Application_Model_Preference::GetDoSoundCloudUpload() )); //SoundCloud Username @@ -55,16 +55,16 @@ class Application_Form_Preferences extends Zend_Form 'label' => 'SoundCloud Username:', 'required' => false, 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetValue("soundcloud_user") + 'value' => Application_Model_Preference::GetSoundCloudUser() )); //SoundCloud Password - $this->addElement('password', 'SoundCloudPassword', array( + $this->addElement('text', 'SoundCloudPassword', array( 'class' => 'input_text', 'label' => 'SoundCloud Password:', 'required' => false, 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetValue("soundcloud_pass") + 'value' => Application_Model_Preference::GetSoundCloudPassword() )); $this->addElement('submit', 'submit', array( diff --git a/application/models/Preference.php b/application/models/Preference.php index 1688fe067..6ecc83ae4 100644 --- a/application/models/Preference.php +++ b/application/models/Preference.php @@ -118,7 +118,7 @@ class Application_Model_Preference Application_Model_Preference::SetValue("soundcloud_password", $password); } - public static function GetSoundCloudUserPassword() { + public static function GetSoundCloudPassword() { return Application_Model_Preference::GetValue("soundcloud_password"); } diff --git a/application/models/Soundcloud.php b/application/models/Soundcloud.php index d1a16247b..ceaa9cc47 100644 --- a/application/models/Soundcloud.php +++ b/application/models/Soundcloud.php @@ -1,31 +1,54 @@ _soundcloud = new Services_Soundcloud($CC_CONFIG['soundcloud-client-id'], $CC_CONFIG['soundcloud-client-secret']); + } -$soundcloud = new Services_Soundcloud('2CLCxcSXYzx7QhhPVHN4A', 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs'); + private function getToken() + { + $username = Application_Model_Preference::GetSoundCloudUser(); + $password = Application_Model_Preference::GetSoundCloudPassword(); -$token = $soundcloud->accessTokenResourceOwner('naomiaro@gmail.com', 'airtime17'); + if($username === "" || $password === "") + { + return false; + } -$track_data = array( - 'track[sharing]' => 'private', - 'track[title]' => 'Test', - 'track[asset_data]' => '@/home/naomi/Music/testoutput.mp3' -); + $token = $this->_soundcloud->accessTokenResourceOwner($username, $password); + + return $token; + } + + public function uploadTrack($filepath, $filename) + { + if($this->getToken()) + { + $track_data = array( + 'track[sharing]' => 'private', + 'track[title]' => $filename, + 'track[asset_data]' => '@' . $filepath + ); + + try { + $response = json_decode( + $this->_soundcloud->post('tracks', $track_data), + true + ); + } + catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { + echo $e->getMessage(); + echo var_dump($track_data); + } + } + } -try { - $response = json_decode( - $soundcloud->post('tracks', $track_data), - true - ); -} -catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { - show_error($e->getMessage()); } - -*/ diff --git a/install/airtime-install.php b/install/airtime-install.php index d3badef95..55d5ba068 100644 --- a/install/airtime-install.php +++ b/install/airtime-install.php @@ -49,6 +49,9 @@ AirtimeInstall::ChangeDirOwnerToWebserver($CC_CONFIG["storageDir"]); echo "* Importing Sample Audio Clips".PHP_EOL; system(__DIR__."/../utils/airtime-import --copy ../audio_samples/ > /dev/null"); +echo "* Python eggs Setup".PHP_EOL; +AirtimeInstall::SetUpPythonEggs(); + echo PHP_EOL."*** Pypo Installation ***".PHP_EOL; system("python ".__DIR__."/../pypo/install/pypo-install.py"); diff --git a/install/installInit.php b/install/installInit.php index 6723b063a..65fb574fb 100644 --- a/install/installInit.php +++ b/install/installInit.php @@ -190,10 +190,17 @@ class AirtimeInstall { system($command); } + public static function SetUpPythonEggs() + { + //install poster streaming upload + $command = "sudo easy_install poster"; + @exec($command); + } + public static function DeleteFilesRecursive($p_path) { $command = "rm -rf $p_path"; exec($command); } -} \ No newline at end of file +} diff --git a/python_apps/eggs/poster-0.8.0-py2.6.egg b/python_apps/eggs/poster-0.8.0-py2.6.egg deleted file mode 100644 index 7af5c8f5e..000000000 Binary files a/python_apps/eggs/poster-0.8.0-py2.6.egg and /dev/null differ diff --git a/python_apps/show-recorder/config.cfg b/python_apps/show-recorder/config.cfg index 274d9d786..f75ea204c 100644 --- a/python_apps/show-recorder/config.cfg +++ b/python_apps/show-recorder/config.cfg @@ -1,5 +1,5 @@ # Hostname -base_url = 'http://campcaster.dev/' +base_url = 'http://localhost/' show_schedule_url = 'Recorder/get-show-schedule/format/json'