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:
naomiaro 2011-03-21 15:48:44 -04:00
parent a3a8ae104a
commit 60649cba8a
10 changed files with 71 additions and 29 deletions

View file

@ -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());
}
*/