SoundCloud - Add release_year metadata field and set default sharing and license types

This commit is contained in:
Duncan Sommerville 2015-06-25 10:53:35 -04:00
parent 67155b136a
commit d91b05a0ae
4 changed files with 18 additions and 7 deletions

View file

@ -97,6 +97,10 @@ define('PROVISIONING_STATUS_ACTIVE' , 'Active');
//TuneIn integration
define("TUNEIN_API_URL", "http://air.radiotime.com/Playing.ashx");
// SoundCloud
define('DEFAULT_SOUNDCLOUD_LICENSE_TYPE', 'all-rights-reserved');
define('DEFAULT_SOUNDCLOUD_SHARING_TYPE', 'public');
// Celery
define('CELERY_PENDING_STATUS', 'PENDING');
define('CELERY_SUCCESS_STATUS', 'SUCCESS');

View file

@ -14,8 +14,8 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
$select->setLabel(_('Default License:'));
$select->setAttrib('class', 'input_select');
$select->setMultiOptions(array(
"no-rights-reserved" => _("The work is in the public domain"),
"all-rights-reserved" => _("All rights are reserved"),
"no-rights-reserved" => _("The work is in the public domain"),
"cc-by" => _("Creative Commons Attribution"),
"cc-by-nc" => _("Creative Commons Attribution Noncommercial"),
"cc-by-nd" => _("Creative Commons Attribution No Derivative Works"),

View file

@ -1452,7 +1452,9 @@ class Application_Model_Preference
// SoundCloud
public static function getDefaultSoundCloudLicenseType() {
return self::getValue("soundcloud_license_type");
$val = self::getValue("soundcloud_license_type");
// If we don't have a value set, return all-rights-reserved by default
return empty($val) ? DEFAULT_SOUNDCLOUD_LICENSE_TYPE : $val;
}
public static function setDefaultSoundCloudLicenseType($value) {
@ -1460,7 +1462,9 @@ class Application_Model_Preference
}
public static function getDefaultSoundCloudSharingType() {
return self::getValue("soundcloud_sharing_type");
$val = self::getValue("soundcloud_sharing_type");
// If we don't have a value set, return public by default
return empty($val) ? DEFAULT_SOUNDCLOUD_SHARING_TYPE : $val;
}
public static function setDefaultSoundCloudSharingType($value) {

View file

@ -69,7 +69,6 @@ class SoundcloudService extends ThirdPartyCeleryService implements OAuth2 {
*/
protected function _getUploadData($file) {
$file = $file->getPropelOrm();
// TODO: Move this into a proper serializer
$trackArray = $this->_serializeTrack($file);
foreach (self::$_SOUNDCLOUD_PREF_FUNCTIONS as $func => $param) {
$val = Application_Model_Preference::$func();
@ -87,6 +86,8 @@ class SoundcloudService extends ThirdPartyCeleryService implements OAuth2 {
* Ignores any null fields, as these will cause the upload to throw a 422
* Unprocessable Entity error
*
* TODO: Move this into a proper serializer
*
* @param $file CcFiles file object
*
* @return array the serialized data
@ -96,6 +97,7 @@ class SoundcloudService extends ThirdPartyCeleryService implements OAuth2 {
'title' => $file->getDbTrackTitle(),
'genre' => $file->getDbGenre(),
'bpm' => $file->getDbBpm(),
'release_year' => $file->getDbYear(),
);
$trackArray = array();
foreach ($fileData as $k => $v) {
@ -108,6 +110,7 @@ class SoundcloudService extends ThirdPartyCeleryService implements OAuth2 {
/**
* Update a ThirdPartyTrackReferences object for a completed upload
*
* TODO: should we have a database layer class to handle Propel operations?
*
* @param $trackId int ThirdPartyTrackReferences identifier