CC-2125 : Soundcloud: ability to retry to upload
if a recorded show in the past does not have a soundcloud file id, context menu action appears to upload to soundcloud if it is enabled in preferences. if a recorded file is on soundcloud the soundcloud icon replaces the record icon.
This commit is contained in:
parent
119e21ec82
commit
1cdbce55a7
|
@ -25,6 +25,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
->addActionContext('edit-show', 'json')
|
||||
->addActionContext('add-show', 'json')
|
||||
->addActionContext('cancel-show', 'json')
|
||||
->addActionContext('upload-to-sound-cloud', 'json')
|
||||
->initContext();
|
||||
|
||||
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
||||
|
@ -145,6 +146,52 @@ class ScheduleController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function uploadToSoundCloudAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$show_instance = $this->_getParam('id');
|
||||
$show_inst = new ShowInstance($show_instance);
|
||||
|
||||
$file = $show_inst->getRecordedFile();
|
||||
|
||||
if(is_null($file)) {
|
||||
$this->view->error = "Recorded file does not exist";
|
||||
return;
|
||||
}
|
||||
|
||||
$show_name = $show_inst->getName();
|
||||
$show_genre = $show_inst->getGenre();
|
||||
$show_start_time = $show_inst->getShowStart();
|
||||
|
||||
if(Application_Model_Preference::GetDoSoundCloudUpload())
|
||||
{
|
||||
for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) {
|
||||
|
||||
$show = new Show($show_inst->getShowId());
|
||||
$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, $tags, $show_start_time, $show_genre);
|
||||
$show_inst->setSoundCloudFileId($soundcloud_id);
|
||||
$this->view->soundcloud_id = $soundcloud_id;
|
||||
break;
|
||||
}
|
||||
catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
|
||||
$code = $e->getHttpCode();
|
||||
if(!in_array($code, array(0, 100))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sleep($CC_CONFIG['soundcloud-connection-wait']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function makeContextMenuAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
|
@ -174,10 +221,18 @@ class ScheduleController extends Zend_Controller_Action
|
|||
'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content');
|
||||
}
|
||||
|
||||
if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp)
|
||||
&& is_null($show->getSoundCloudFileId())
|
||||
&& Application_Model_Preference::GetDoSoundCloudUpload()) {
|
||||
$menu[] = array('action' => array('type' => 'fn',
|
||||
'callback' => "window['uploadToSoundCloud']($id)"),
|
||||
'title' => 'Upload to Soundcloud');
|
||||
}
|
||||
|
||||
|
||||
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
||||
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
|
||||
$user->isAdmin()) {
|
||||
$user->isAdmin() && !$show->isRecorded()) {
|
||||
$menu[] = array('action' => array('type' => 'fn',
|
||||
'callback' => "window['confirmCancelShow']($id)"),
|
||||
'title' => 'Cancel Current Show');
|
||||
|
|
|
@ -648,6 +648,26 @@ class ShowInstance {
|
|||
return $showInstance->getDbSoundCloudId();
|
||||
}
|
||||
|
||||
public function getRecordedFile()
|
||||
{
|
||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||
$file_id = $showInstance->getDbRecordedFile();
|
||||
|
||||
if(isset($file_id)) {
|
||||
$file = StoredFile::Recall($file_id);
|
||||
|
||||
if (PEAR::isError($file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(file_exists($file->getRealFilePath())) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setShowStart($start)
|
||||
{
|
||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -1511,6 +1511,11 @@ div.success{
|
|||
background:url(images/icon_soundcloud.png) no-repeat 0 0;
|
||||
width:21px;
|
||||
}
|
||||
.small-icon.progress {
|
||||
background:url(images/upload-icon.gif) no-repeat;
|
||||
background-color:black;
|
||||
background-position:center;
|
||||
}
|
||||
.medium-icon {
|
||||
display:block;
|
||||
width:25px;
|
||||
|
@ -1585,4 +1590,4 @@ dd.radio-inline-list, .preferences dd.radio-inline-list {
|
|||
}
|
||||
.preferences dd.block-display .input_text_area, .preferences dd.block-display .input_text {
|
||||
width: 99.5%;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,8 +148,8 @@ function viewDisplay( view ) {
|
|||
|
||||
function eventRender(event, element, view) {
|
||||
|
||||
//only put progress bar on shows that aren't being recorded and are not a rebroadcast.
|
||||
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 0 /* && event.rebroadcast === 0 */) {
|
||||
//only put progress bar on shows that aren't being recorded.
|
||||
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 0) {
|
||||
var div = $('<div/>');
|
||||
div
|
||||
.height('5px')
|
||||
|
@ -168,15 +168,17 @@ function eventRender(event, element, view) {
|
|||
}
|
||||
|
||||
//add the record/rebroadcast icons if needed.
|
||||
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 1) {
|
||||
|
||||
//record icon (only if not on soundcloud, will always be true for future events)
|
||||
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 1 && event.soundcloud_id === -1) {
|
||||
|
||||
$(element).find(".fc-event-time").after('<span class="small-icon recording"></span>');
|
||||
}
|
||||
if(view.name === 'month' && event.record === 1) {
|
||||
if(view.name === 'month' && event.record === 1 && event.soundcloud_id === -1) {
|
||||
|
||||
$(element).find(".fc-event-title").after('<span class="small-icon recording"></span>');
|
||||
}
|
||||
|
||||
//rebroadcast icon
|
||||
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.rebroadcast === 1) {
|
||||
|
||||
$(element).find(".fc-event-time").after('<span class="small-icon rebroadcast"></span>');
|
||||
|
@ -185,12 +187,12 @@ function eventRender(event, element, view) {
|
|||
|
||||
$(element).find(".fc-event-title").after('<span class="small-icon rebroadcast"></span>');
|
||||
}
|
||||
|
||||
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id != -1 && event.record === 1) {
|
||||
//soundcloud icon
|
||||
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id !== -1 && event.record === 1) {
|
||||
|
||||
$(element).find(".fc-event-time").after('<span class="small-icon soundcloud"></span>');
|
||||
}
|
||||
if(view.name === 'month' && event.soundcloud_id != -1 && event.record === 1) {
|
||||
if(view.name === 'month' && event.soundcloud_id !== -1 && event.record === 1) {
|
||||
|
||||
$(element).find(".fc-event-title").after('<span class="small-icon soundcloud"></span>');
|
||||
}
|
||||
|
|
|
@ -165,6 +165,30 @@ function confirmCancelShow(show_instance_id){
|
|||
}
|
||||
}
|
||||
|
||||
function uploadToSoundCloud(show_instance_id){
|
||||
|
||||
var url = "/Schedule/upload-to-sound-cloud";
|
||||
var span = $(window.triggerElement).find(".recording");
|
||||
|
||||
span.removeClass("recording")
|
||||
.addClass("progress");
|
||||
|
||||
$.post(url,
|
||||
{id: show_instance_id, format: "json"},
|
||||
function(data){
|
||||
if(data.error) {
|
||||
span.removeClass("progress")
|
||||
.addClass("recording");
|
||||
|
||||
alert(data.error);
|
||||
return;
|
||||
}
|
||||
span.removeClass("progress")
|
||||
.addClass("soundcloud");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function buildContentDialog(json){
|
||||
var dialog = $(json.dialog);
|
||||
|
||||
|
|
Loading…
Reference in New Issue