CC-1987 : Automatic upload of recorded shows to Soundcloud
created Soundcloud.php in models, added upload track method. using python-setuptools in install to find poster package to be able to upload recoded file to airtime and then to soundcloud.
This commit is contained in:
parent
a3a8ae104a
commit
60649cba8a
|
@ -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';
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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().' }');
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,54 @@
|
|||
<?php
|
||||
|
||||
require_once 'Soundcloud.php';
|
||||
require_once 'soundcloud-api/Services/Soundcloud.php';
|
||||
|
||||
class ATSoundcloud {
|
||||
|
||||
/*
|
||||
private $_soundcloud;
|
||||
|
||||
require_once 'Soundcloud.php';
|
||||
public function __construct()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$this->_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());
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
# Hostname
|
||||
base_url = 'http://campcaster.dev/'
|
||||
base_url = 'http://localhost/'
|
||||
|
||||
show_schedule_url = 'Recorder/get-show-schedule/format/json'
|
||||
|
||||
|
|
Loading…
Reference in New Issue