Merge branch 'master' of dev.sourcefabric.org:airtime

This commit is contained in:
paul.baranowski 2011-03-06 22:43:07 -05:00
commit 17e848c549
11 changed files with 65 additions and 34 deletions

View file

@ -14,7 +14,6 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('error')) ->add(new Zend_Acl_Resource('error'))
->add(new Zend_Acl_Resource('login')) ->add(new Zend_Acl_Resource('login'))
->add(new Zend_Acl_Resource('playlist')) ->add(new Zend_Acl_Resource('playlist'))
->add(new Zend_Acl_Resource('sideplaylist'))
->add(new Zend_Acl_Resource('plupload')) ->add(new Zend_Acl_Resource('plupload'))
->add(new Zend_Acl_Resource('schedule')) ->add(new Zend_Acl_Resource('schedule'))
->add(new Zend_Acl_Resource('api')) ->add(new Zend_Acl_Resource('api'))
@ -30,12 +29,14 @@ $ccAcl->allow('G', 'index')
->allow('G', 'error') ->allow('G', 'error')
->allow('G', 'nowplaying') ->allow('G', 'nowplaying')
->allow('G', 'api') ->allow('G', 'api')
//->allow('G', 'plupload', array('upload-recorded'))
->allow('G', 'recorder') ->allow('G', 'recorder')
->allow('G', 'schedule') ->allow('G', 'schedule')
->allow('G', 'dashboard') ->allow('G', 'dashboard')
//->allow('H', 'plupload', array('plupload', 'upload', 'index'))
->allow('H', 'plupload')
->allow('H', 'library') ->allow('H', 'library')
->allow('H', 'search') ->allow('H', 'search')
->allow('H', 'plupload')
->allow('H', 'playlist') ->allow('H', 'playlist')
->allow('A', 'user') ->allow('A', 'user')
->allow('A', 'preference'); ->allow('A', 'preference');

View file

@ -5,22 +5,13 @@ class PluploadController extends Zend_Controller_Action
public function init() public function init()
{ {
if(!Zend_Auth::getInstance()->hasIdentity())
{
$this->_redirect('login/index');
}
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('upload', 'json') $ajaxContext->addActionContext('upload', 'json')
->addActionContext('upload-recorded', 'json')
->initContext(); ->initContext();
} }
public function indexAction() public function upload($targetDir)
{
// action body
}
public function uploadAction()
{ {
// HTTP headers for no cache etc // HTTP headers for no cache etc
header('Content-type: text/plain; charset=UTF-8'); header('Content-type: text/plain; charset=UTF-8');
@ -31,7 +22,7 @@ class PluploadController extends Zend_Controller_Action
header("Pragma: no-cache"); header("Pragma: no-cache");
// Settings // Settings
$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload"; //$targetDir = ini_get("upload_tmp_dir"); //. DIRECTORY_SEPARATOR . "plupload";
$cleanupTargetDir = false; // Remove old files $cleanupTargetDir = false; // Remove old files
$maxFileAge = 60 * 60; // Temp file age in seconds $maxFileAge = 60 * 60; // Temp file age in seconds
@ -159,6 +150,23 @@ class PluploadController extends Zend_Controller_Action
die('{"jsonrpc" : "2.0", "id" : '.$storedFile->getId().' }'); die('{"jsonrpc" : "2.0", "id" : '.$storedFile->getId().' }');
} }
public function indexAction()
{
// action body
}
public function uploadAction()
{
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
$this->upload($upload_dir);
}
public function uploadRecordedAction()
{
$upload_dir = ini_get("upload_tmp_dir");
$this->upload($upload_dir);
}
public function pluploadAction() public function pluploadAction()
{ {
$this->view->headScript()->appendFile('/js/plupload/plupload.full.min.js','text/javascript'); $this->view->headScript()->appendFile('/js/plupload/plupload.full.min.js','text/javascript');

View file

@ -7,6 +7,7 @@ class RecorderController extends Zend_Controller_Action
{ {
$ajaxContext = $this->_helper->getHelper('contextSwitch'); $ajaxContext = $this->_helper->getHelper('contextSwitch');
$ajaxContext->addActionContext('get-show-schedule', 'json') $ajaxContext->addActionContext('get-show-schedule', 'json')
->addActionContext('get-uploaded-file', 'json')
->initContext(); ->initContext();
} }
@ -17,15 +18,10 @@ class RecorderController extends Zend_Controller_Action
public function getShowScheduleAction() public function getShowScheduleAction()
{ {
//$from = $this->_getParam("from");
//$to = $this->_getParam("to");
$today_timestamp = date("Y-m-d H:i:s"); $today_timestamp = date("Y-m-d H:i:s");
$this->view->shows = Show::getShows($today_timestamp, null, $excludeInstance=NULL, $onlyRecord=TRUE); $this->view->shows = Show::getShows($today_timestamp, null, $excludeInstance=NULL, $onlyRecord=TRUE);
} }
} }

View file

@ -110,7 +110,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
{ {
$controller = strtolower($request->getControllerName()); $controller = strtolower($request->getControllerName());
if ($controller == 'api' || $controller == 'recorder'){ if ($controller == 'api' || $controller == 'recorder' || $controller == 'plupload' && $request->getActionName() == 'upload-recorded'){
$this->setRoleName("G"); $this->setRoleName("G");
} }
@ -143,6 +143,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$this->setRoleName($userInfo->type); $this->setRoleName($userInfo->type);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->_acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName); Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName);
$resourceName = ''; $resourceName = '';

View file

@ -127,9 +127,6 @@ class ScheduleGroup {
if (empty($length)) { if (empty($length)) {
return new PEAR_Error("Length is empty."); return new PEAR_Error("Length is empty.");
} }
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
return new PEAR_Error("Schedule conflict.", 555);
}
// Insert all items into the schedule // Insert all items into the schedule
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");

View file

@ -18,7 +18,6 @@ if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
createAPIKey(); createAPIKey();
require_once(dirname(__FILE__).'/../application/configs/conf.php'); require_once(dirname(__FILE__).'/../application/configs/conf.php');
//require_once(dirname(__FILE__).'/../application/models/GreenBox.php');
require_once(dirname(__FILE__).'/installInit.php'); require_once(dirname(__FILE__).'/installInit.php');
@ -36,8 +35,8 @@ function rand_string($len=20, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
function createAPIKey(){ function createAPIKey(){
$api_key = rand_string(); $api_key = rand_string();
updateINIKeyValues('../build/airtime.conf', 'api_key', $api_key); updateINIKeyValues(__DIR__.'/../build/airtime.conf', 'api_key', $api_key);
updateINIKeyValues('../pypo/config.cfg', 'api_key', "'$api_key'"); updateINIKeyValues(__DIR__.'/../pypo/config.cfg', 'api_key', "'$api_key'");
} }
function checkIfRoot(){ function checkIfRoot(){

View file

@ -110,6 +110,7 @@ function viewDisplay( view ) {
var calendarEl = this; var calendarEl = this;
var select = $('<select class="schedule_change_slots input_select"/>') var select = $('<select class="schedule_change_slots input_select"/>')
.append('<option value="1">1m</option>')
.append('<option value="5">5m</option>') .append('<option value="5">5m</option>')
.append('<option value="10">10m</option>') .append('<option value="10">10m</option>')
.append('<option value="15">15m</option>') .append('<option value="15">15m</option>')

View file

@ -17,8 +17,10 @@ def append_title(m) =
end end
def crossfade(s) def crossfade(s)
s = fade.in(type="log", s) #duration is automatically overwritten by metadata fields passed in
s = fade.out(type="log", s) #with audio
s = fade.in(type="log", duration=0., s)
s = fade.out(type="log", duration=0., s)
fader = fun (a,b) -> add(normalize=false,[b,a]) fader = fun (a,b) -> add(normalize=false,[b,a])
cross(fader,s) cross(fader,s)
end end
@ -42,7 +44,7 @@ def add_skip_command(s)
def skip(_) def skip(_)
l = list.hd(server.execute("queue.queue")) l = list.hd(server.execute("queue.queue"))
l = string.split(separator=" ",l) l = string.split(separator=" ",l)
list.iter(fun (rid) -> ignore(server.execute(queue.ignore #{rid}")), l) list.iter(fun (rid) -> ignore(server.execute("queue.ignore #{rid}")), l)
source.skip(s) source.skip(s)
"Done!" "Done!"

Binary file not shown.

View file

@ -1,8 +1,9 @@
# Hostname # Hostname
base_url = 'http://campcaster.dev/' base_url = 'http://campcaster.dev/'
# URL to get the version number of the server API
show_schedule_url = 'Recorder/get-show-schedule/format/json' show_schedule_url = 'Recorder/get-show-schedule/format/json'
upload_file_url = 'Plupload/upload-recorded/format/json'
# base path to store recordered shows at # base path to store recordered shows at
base_recorded_files = '/home/naomi/Music/' base_recorded_files = '/home/naomi/Music/'

View file

@ -107,12 +107,37 @@ def get_shows():
process_shows(shows) process_shows(shows)
check_record() check_record()
def upload_file():
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2
# Register the streaming http handlers with urllib2
register_openers()
# Start the multipart/form-data encoding of the file "DSC0001.jpg"
# "image1" is the name of the parameter, which is normally set
# via the "name" parameter of the HTML <input> tag.
# 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("/home/naomi/Music/testoutput.mp3", "rb"), 'name': 'crazy.mp3'})
url = config["base_url"] + config["upload_file_url"]
req = urllib2.Request(url, datagen, headers)
response = urllib2.urlopen(req).read().strip()
print response
if __name__ == '__main__': if __name__ == '__main__':
while True: # while True:
get_shows() # get_shows()
time.sleep(30) # time.sleep(30)
upload_file()