CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.
This commit is contained in:
parent
514777e8d2
commit
b11cbd8159
4546 changed files with 138 additions and 51 deletions
94
airtime_mvc/application/models/Soundcloud.php
Normal file
94
airtime_mvc/application/models/Soundcloud.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
require_once 'soundcloud-api/Services/Soundcloud.php';
|
||||
|
||||
class ATSoundcloud {
|
||||
|
||||
private $_soundcloud;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$this->_soundcloud = new Services_Soundcloud($CC_CONFIG['soundcloud-client-id'], $CC_CONFIG['soundcloud-client-secret']);
|
||||
}
|
||||
|
||||
private function getToken()
|
||||
{
|
||||
$username = Application_Model_Preference::GetSoundCloudUser();
|
||||
$password = Application_Model_Preference::GetSoundCloudPassword();
|
||||
|
||||
if($username === "" || $password === "")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$token = $this->_soundcloud->accessTokenResourceOwner($username, $password);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function uploadTrack($filepath, $filename, $description, $tags=array(), $release=null, $genre=null)
|
||||
{
|
||||
if($this->getToken())
|
||||
{
|
||||
if(count($tags)) {
|
||||
$tags = join(" ", $tags);
|
||||
$tags = $tags." ".Application_Model_Preference::GetSoundCloudTags();
|
||||
}
|
||||
else {
|
||||
$tags = Application_Model_Preference::GetSoundCloudTags();
|
||||
}
|
||||
|
||||
$track_data = array(
|
||||
'track[sharing]' => 'private',
|
||||
'track[title]' => $filename,
|
||||
'track[asset_data]' => '@' . $filepath,
|
||||
'track[tag_list]' => $tags,
|
||||
'track[description]' => $description,
|
||||
'track[downloadable]' => true,
|
||||
|
||||
);
|
||||
|
||||
if(isset($release)) {
|
||||
$release = str_replace(" ", "-", $release);
|
||||
$release = str_replace(":", "-", $release);
|
||||
|
||||
//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];
|
||||
}
|
||||
|
||||
if (isset($genre) && $genre != "") {
|
||||
$track_data['track[genre]'] = $genre;
|
||||
}
|
||||
else {
|
||||
$default_genre = Application_Model_Preference::GetSoundCloudTrackType();
|
||||
if ($genre != "") {
|
||||
$track_data['track[genre]'] = $default_genre;
|
||||
}
|
||||
}
|
||||
|
||||
$track_type = Application_Model_Preference::GetSoundCloudTrackType();
|
||||
if ($track_type != "") {
|
||||
$track_data['track[track_type]'] = $track_type;
|
||||
}
|
||||
|
||||
$license = Application_Model_Preference::GetSoundCloudLicense();
|
||||
if ($license != "") {
|
||||
$track_data['track[license]'] = $license;
|
||||
}
|
||||
|
||||
$response = json_decode(
|
||||
$this->_soundcloud->post('tracks', $track_data),
|
||||
true
|
||||
);
|
||||
|
||||
return $response["id"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue