Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
70dd2a4838
|
@ -250,10 +250,6 @@ class ApiController extends Zend_Controller_Action
|
|||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
|
@ -265,16 +261,19 @@ class ApiController extends Zend_Controller_Action
|
|||
$upload_dir = ini_get("upload_tmp_dir");
|
||||
$file = StoredFile::uploadFile($upload_dir);
|
||||
|
||||
if(Application_Model_Preference::GetDoSoundCloudUpload())
|
||||
{
|
||||
$soundcloud = new ATSoundcloud();
|
||||
$soundcloud->uploadTrack($file->getRealFilePath(), $file->getName());
|
||||
}
|
||||
|
||||
$show_instance = $this->_getParam('show_instance');
|
||||
|
||||
$show = new ShowInstance($show_instance);
|
||||
$show->setRecordedFile($file->getId());
|
||||
$show_inst = new ShowInstance($show_instance);
|
||||
$show_inst->setRecordedFile($file->getId());
|
||||
|
||||
if(Application_Model_Preference::GetDoSoundCloudUpload())
|
||||
{
|
||||
$show = new Show($show_inst->getShowId());
|
||||
$description = $show->getDescription();
|
||||
|
||||
$soundcloud = new ATSoundcloud();
|
||||
$soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description);
|
||||
}
|
||||
|
||||
$this->view->id = $file->getId();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]);
|
||||
Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]);
|
||||
Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]);
|
||||
Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
|
||||
Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
|
||||
Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]);
|
||||
|
||||
$this->view->statusMsg = "Preferences Updated.";
|
||||
}
|
||||
|
|
|
@ -67,6 +67,14 @@ class Application_Form_Preferences extends Zend_Form
|
|||
'value' => Application_Model_Preference::GetSoundCloudPassword()
|
||||
));
|
||||
|
||||
// Add the description element
|
||||
$this->addElement('textarea', 'SoundCloudTags', array(
|
||||
'label' => 'space separated SoundCloud Tags',
|
||||
'required' => false,
|
||||
'class' => 'input_text_area',
|
||||
'value' => Application_Model_Preference::GetSoundCloudTags()
|
||||
));
|
||||
|
||||
$this->addElement('submit', 'submit', array(
|
||||
'class' => 'ui-button ui-state-default',
|
||||
'ignore' => true,
|
||||
|
|
|
@ -124,5 +124,13 @@ class Application_Model_Preference
|
|||
return Application_Model_Preference::GetValue("soundcloud_password");
|
||||
}
|
||||
|
||||
public static function SetSoundCloudTags($tags) {
|
||||
Application_Model_Preference::SetValue("soundcloud_tags", $tags);
|
||||
}
|
||||
|
||||
public static function GetSoundCloudTags() {
|
||||
return Application_Model_Preference::GetValue("soundcloud_tags");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,24 @@ class ATSoundcloud {
|
|||
return $token;
|
||||
}
|
||||
|
||||
public function uploadTrack($filepath, $filename)
|
||||
public function uploadTrack($filepath, $filename, $description, $tags=array())
|
||||
{
|
||||
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[asset_data]' => '@' . $filepath,
|
||||
'track[tag_list]' => $tags,
|
||||
'track[description]' => $description
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -43,12 +53,17 @@ class ATSoundcloud {
|
|||
$this->_soundcloud->post('tracks', $track_data),
|
||||
true
|
||||
);
|
||||
|
||||
echo var_dump($response);
|
||||
}
|
||||
catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
|
||||
echo $e->getMessage();
|
||||
echo var_dump($track_data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "could not get soundcloud token";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<div id="schedule-add-show" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||
<div class="button-bar">
|
||||
<a href="#" id="add-show-close" class="icon-link"><span class="ui-icon ui-icon-circle-close"></span>Close</a>
|
||||
<button id="add-show-submit" class="right-floated">Add this show</button>
|
||||
<button aria-disabled="false" role="button" id="add-show-submit" class="right-floated ui-button ui-widget ui-state-default ui-button-text-icon-primary">
|
||||
<span class="ui-icon ui-icon-plusthick"></span>
|
||||
<span class="ui-button-text">Add this show</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<h3 class="collapsible-header"><span class="arrow-icon"></span>What</h3>
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
<div id="users_wrapper" class="dataTables_wrapper">
|
||||
|
||||
<div class="button-holder">
|
||||
<button type="button" id="add_user_button" name="search_add_group" class="ui-button ui-widget ui-state-default ui-button-text-icon-primary"><span class="ui-button-text">New User</span></button>
|
||||
<button type="button" id="add_user_button" name="search_add_group" class="ui-button ui-widget ui-state-default ui-button-text-icon-primary">
|
||||
<span class="ui-icon ui-icon-plusthick"></span>
|
||||
<span class="ui-button-text">New User</span></button>
|
||||
</div>
|
||||
|
||||
<table cellspacing="0" cellpadding="0" style="" id="users_datatable" class="datatable">
|
||||
|
|
|
@ -182,7 +182,6 @@ function setAddShowEvents() {
|
|||
});
|
||||
|
||||
form.find("#add-show-submit")
|
||||
.button()
|
||||
.click(function(event){
|
||||
event.preventDefault();
|
||||
|
||||
|
|
|
@ -291,9 +291,9 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
response = ''
|
||||
try:
|
||||
url = self.config["base_url"] + self.config["api_base"] + self.config["show_schedule_url"]
|
||||
#logger.debug(url)
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
logger.debug(url)
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
|
||||
response = urllib.urlopen(url)
|
||||
response = json.loads(response.read())
|
||||
logger.info("shows %s", response)
|
||||
|
@ -308,9 +308,8 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
response = ''
|
||||
try:
|
||||
url = self.config["base_url"] + self.config["api_base"] + self.config["upload_file_url"]
|
||||
#logger.debug(url)
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
logger.debug(url)
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
|
||||
request = urllib2.Request(url, data, headers)
|
||||
response = urllib2.urlopen(request).read().strip()
|
||||
|
|
|
@ -109,14 +109,14 @@ class Record():
|
|||
show_end = getDateTimeObj(show[u'ends'])
|
||||
time_delta = show_end - show_starts
|
||||
|
||||
self.shows_to_record[show[u'starts']] = [time_delta, show[u'instance_id']]
|
||||
self.shows_to_record[show[u'starts']] = [time_delta, show[u'instance_id'], show[u'name']]
|
||||
|
||||
|
||||
def check_record(self):
|
||||
|
||||
tnow = datetime.datetime.now()
|
||||
sorted_show_keys = sorted(self.shows_to_record.keys())
|
||||
print sorted_show_keys
|
||||
|
||||
start_time = sorted_show_keys[0]
|
||||
next_show = getDateTimeObj(start_time)
|
||||
|
||||
|
@ -132,7 +132,10 @@ class Record():
|
|||
|
||||
show_length = self.shows_to_record[start_time][0]
|
||||
show_instance = self.shows_to_record[start_time][1]
|
||||
show = ShowRecorder(show_instance, show_length.seconds, start_time, filetype="mp3")
|
||||
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.start()
|
||||
|
||||
#remove show from shows to record.
|
||||
|
|
Loading…
Reference in New Issue