Cleaned up soundcloud

This commit is contained in:
Rudi Grinberg 2012-10-26 18:45:27 -04:00
parent faf4052fda
commit d6a4f2f713
1 changed files with 58 additions and 57 deletions

View File

@ -25,66 +25,67 @@ class Application_Model_Soundcloud
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();
}
{
$downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1';
$track_data = array(
'track[sharing]' => 'private',
'track[title]' => $filename,
'track[asset_data]' => '@' . $filepath,
'track[tag_list]' => $tags,
'track[description]' => $description,
'track[downloadable]' => $downloadable,
);
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::GetSoundCloudGenre();
if ($default_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;
} else {
if (!$this->getToken()) {
throw new NoSoundCloundToken();
}
if (count($tags)) {
$tags = join(" ", $tags);
$tags = $tags." ".Application_Model_Preference::GetSoundCloudTags();
} else {
$tags = Application_Model_Preference::GetSoundCloudTags();
}
$downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1';
$track_data = array(
'track[sharing]' => 'private',
'track[title]' => $filename,
'track[asset_data]' => '@' . $filepath,
'track[tag_list]' => $tags,
'track[description]' => $description,
'track[downloadable]' => $downloadable,
);
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::GetSoundCloudGenre();
if ($default_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;
}
public static function uploadSoundcloud($id)