CC-2097: Show-recorder: Use RabbitMQ, api_client, and the structure of pypofetch
using api client now
This commit is contained in:
parent
9546d9670e
commit
c727c338af
10 changed files with 334 additions and 274 deletions
|
@ -6,8 +6,10 @@ class ApiController extends Zend_Controller_Action
|
|||
public function init()
|
||||
{
|
||||
/* Initialize action controller here */
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('version', 'json')
|
||||
$context = $this->_helper->getHelper('contextSwitch');
|
||||
$context->addActionContext('version', 'json')
|
||||
->addActionContext('recorded-shows', 'json')
|
||||
->addActionContext('upload-recorded', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
|
@ -150,12 +152,6 @@ class ApiController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function recordedShowsAction()
|
||||
{
|
||||
$today_timestamp = date("Y-m-d H:i:s");
|
||||
$this->view->shows = Show::getShows($today_timestamp, null, $excludeInstance=NULL, $onlyRecord=TRUE);
|
||||
}
|
||||
|
||||
public function notifyMediaItemStartPlayAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
@ -222,5 +218,54 @@ class ApiController extends Zend_Controller_Action
|
|||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function recordedShowsAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$today_timestamp = date("Y-m-d H:i:s");
|
||||
$this->view->shows = Show::getShows($today_timestamp, null, $excludeInstance=NULL, $onlyRecord=TRUE);
|
||||
}
|
||||
|
||||
public function uploadRecordedAction()
|
||||
{
|
||||
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"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$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());
|
||||
|
||||
$this->view->id = $file->getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue