CC-2110 : Soundcloud file metadata

added all defaults or ways to input a default for soundcloud metadata.
This commit is contained in:
naomiaro 2011-04-02 16:33:45 -04:00
parent a6927442ec
commit 5a105ff4c8
7 changed files with 126 additions and 10 deletions

View File

@ -276,6 +276,8 @@ class ApiController extends Zend_Controller_Action
$file = StoredFile::uploadFile($upload_dir);
$show_instance = $this->_getParam('show_instance');
$show_name = $this->_getParam('show_name');
$start_time = $this->_getParam('start_time');
$show_inst = new ShowInstance($show_instance);
$show_inst->setRecordedFile($file->getId());
@ -288,9 +290,11 @@ class ApiController extends Zend_Controller_Action
$description = $show->getDescription();
$hosts = $show->getHosts();
$tags = array_merge($hosts, array($show_name));
try {
$soundcloud = new ATSoundcloud();
$soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $hosts);
$soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $start_time);
$show_inst->setSoundCloudFileId($soundcloud_id);
break;
}

View File

@ -35,6 +35,9 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]);
Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]);
Application_Model_Preference::SetSoundCloudGenre($values["SoundCloudGenre"]);
Application_Model_Preference::SetSoundCloudTrackType($values["SoundCloudTrackType"]);
Application_Model_Preference::SetSoundCloudLicense($values["SoundCloudLicense"]);
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
}

View File

@ -409,6 +409,9 @@ class ScheduleController extends Zend_Controller_Action
$rebroad = $formRebroadcast->checkReliantFields($data);
}
}
else {
$rebroad = 1;
}
}
else {
$formRebroadcast->reset();
@ -422,6 +425,9 @@ class ScheduleController extends Zend_Controller_Action
$rebroadAb = $formAbsoluteRebroadcast->checkReliantFields($data);
}
}
else {
$rebroadAb = 1;
}
}
$who = $formWho->isValid($data);

View File

@ -82,6 +82,56 @@ class Application_Form_Preferences extends Zend_Form
'value' => Application_Model_Preference::GetSoundCloudTags()
));
//SoundCloud default genre
$this->addElement('text', 'SoundCloudGenre', array(
'class' => 'input_text',
'label' => 'Default Genre:',
'required' => false,
'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetSoundCloudGenre()
));
$select = new Zend_Form_Element_Select('SoundCloudTrackType');
$select->setLabel('Default Track Type:');
$select->setAttrib('class', 'input_select');
$select->setMultiOptions(array(
"" => "",
"original" => "Original",
"remix" => "Remix",
"live" => "Live",
"recording" => "Recording",
"spoken" => "Spoken",
"podcast" => "Podcast",
"demo" => "Demo",
"in progress" => "Work in progress",
"stem" => "Stem",
"loop" => "Loop",
"sound effect" => "Sound Effect",
"sample" => "One Shot Sample",
"other" => "Other"
));
$select->setRequired(false);
$select->setValue(Application_Model_Preference::GetSoundCloudTrackType());
$this->addElement($select);
$select = new Zend_Form_Element_Select('SoundCloudLicense');
$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",
"cc-by" => "Creative Commons Attribution",
"cc-by-nc" => "Creative Commons Attribution Noncommercial",
"cc-by-nd" => "Creative Commons Attribution No Derivative Works",
"cc-by-sa" => "Creative Commons Attribution Share Alike",
"cc-by-nc-nd" => "Creative Commons Attribution Noncommercial Non Derivate Works",
"cc-by-nc-sa" => "Creative Commons Attribution Noncommercial Share Alike"
));
$select->setRequired(false);
$select->setValue(Application_Model_Preference::GetSoundCloudLicense());
$this->addElement($select);
$this->addElement('submit', 'submit', array(
'class' => 'ui-button ui-state-default',
'ignore' => true,

View File

@ -133,6 +133,30 @@ class Application_Model_Preference
return Application_Model_Preference::GetValue("soundcloud_tags");
}
public static function SetSoundCloudGenre($genre) {
Application_Model_Preference::SetValue("soundcloud_genre", $genre);
}
public static function GetSoundCloudGenre() {
return Application_Model_Preference::GetValue("soundcloud_genre");
}
public static function SetSoundCloudTrackType($track_type) {
Application_Model_Preference::SetValue("soundcloud_tracktype", $track_type);
}
public static function GetSoundCloudTrackType() {
return Application_Model_Preference::GetValue("soundcloud_tracktype");
}
public static function SetSoundCloudLicense($license) {
Application_Model_Preference::SetValue("soundcloud_license", $license);
}
public static function GetSoundCloudLicense() {
return Application_Model_Preference::GetValue("soundcloud_license");
}
public static function SetAllow3rdPartyApi($bool) {
Application_Model_Preference::SetValue("third_party_api", $bool);
}

View File

@ -28,7 +28,7 @@ class ATSoundcloud {
return $token;
}
public function uploadTrack($filepath, $filename, $description, $tags=array())
public function uploadTrack($filepath, $filename, $description, $tags=array(), $release=null)
{
if($this->getToken())
{
@ -50,6 +50,33 @@ class ATSoundcloud {
);
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];
}
$genre = Application_Model_Preference::GetSoundCloudGenre();
if ($genre != "") {
$track_data['track[genre]'] = $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

View File

@ -47,18 +47,20 @@ def getDateTimeObj(time):
class ShowRecorder(Thread):
def __init__ (self, show_instance, filelength, filename, filetype):
def __init__ (self, show_instance, filelength, show_name, start_time, filetype):
Thread.__init__(self)
self.api_client = api_client.api_client_factory(config)
self.filelength = filelength
self.filename = filename
self.show_name = show_name
self.start_time = start_time
self.filetype = filetype
self.show_instance = show_instance
def record_show(self):
length = str(self.filelength)+".0"
filename = self.filename.replace(" ", "-")
filename = self.show_name+" "+self.start_time
filename = filename.replace(" ", "-")
filepath = "%s%s.%s" % (config["base_recorded_files"], filename, self.filetype)
command = "ecasound -i alsa -o %s -t:%s" % (filepath, length)
@ -82,7 +84,8 @@ class ShowRecorder(Thread):
# headers contains the necessary Content-Type and Content-Length
# datagen is a generator object that yields the encoded parameters
datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance})
datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance, \
'show_name': self.show_name, 'start_time': self.start_time})
self.api_client.upload_recorded_show(datagen, headers)
@ -134,9 +137,8 @@ class Record():
show_length = self.shows_to_record[start_time][0]
show_instance = self.shows_to_record[start_time][1]
show_name = self.shows_to_record[start_time][2]
filename = show_name+"-"+start_time
show = ShowRecorder(show_instance, show_length.seconds, filename, filetype="mp3")
show = ShowRecorder(show_instance, show_length.seconds, show_name, start_time, filetype="mp3", )
show.start()
#remove show from shows to record.