Merge branch 'master' of dev.sourcefabric.org:campcaster
This commit is contained in:
commit
bef06bd0ff
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
|
||||
$api_key = $_GET['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;
|
||||
}
|
||||
|
||||
print json_encode(array("version"=>CAMPCASTER_VERSION));
|
||||
?>
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
require_once('../backend/StoredFile.php');
|
||||
|
||||
$api_key = $_GET['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;
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$filename = $_GET["file"];
|
||||
$file_id = substr($filename, 0, strpos($filename, "."));
|
||||
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
|
||||
$media = StoredFile::RecallByGunid($file_id);
|
||||
if ($media != null && !PEAR::isError($media)) {
|
||||
//var_dump($media);
|
||||
$filepath = $media->getRealFilePath();
|
||||
if(!is_file($filepath))
|
||||
{
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
//print 'Ressource in database, but not in storage. Sorry.';
|
||||
exit;
|
||||
}
|
||||
|
||||
// !! binary mode !!
|
||||
$fp = fopen($filepath, 'rb');
|
||||
|
||||
header("Content-Type: audio/mpeg");
|
||||
header("Content-Length: " . filesize($filepath));
|
||||
|
||||
fpassthru($fp);
|
||||
}
|
||||
else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
exit;
|
||||
|
||||
?>
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
require_once('../backend/Schedule.php');
|
||||
|
||||
$api_key = $_GET['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;
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$schedule_group_id = $_GET["schedule_id"];
|
||||
$media_id = $_GET["media_id"];
|
||||
$f = StoredFile::RecallByGunid($media_id);
|
||||
|
||||
if (is_numeric($schedule_group_id)) {
|
||||
$sg = new ScheduleGroup($schedule_group_id);
|
||||
if ($sg->exists()) {
|
||||
$result = $sg->notifyMediaItemStartPlay($f->getId());
|
||||
if (!PEAR::isError($result)) {
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
exit;
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"DB Error:".$result->getMessage()));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"Schedule group does not exist: ".$schedule_group_id));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message" => "Incorrect or non-numeric arguments given."));
|
||||
}
|
||||
?>
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
require_once('../backend/Schedule.php');
|
||||
|
||||
$api_key = $_GET['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;
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$schedule_group_id = $_GET["schedule_id"];
|
||||
if (is_numeric($schedule_group_id)) {
|
||||
$sg = new ScheduleGroup($schedule_group_id);
|
||||
if ($sg->exists()) {
|
||||
$result = $sg->notifyGroupStartPlay();
|
||||
if (!PEAR::isError($result)) {
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
exit;
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"DB Error:".$result->getMessage()));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"Schedule group does not exist: ".$schedule_group_id));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"Incorrect or non-numeric arguments given."));
|
||||
exit;
|
||||
}
|
||||
?>
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
require_once('../backend/Schedule.php');
|
||||
|
||||
$api_key = $_GET['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;
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$from = $_GET["from"];
|
||||
$to = $_GET["to"];
|
||||
echo Schedule::ExportRangeAsJson($from, $to);
|
||||
?>
|
|
@ -83,10 +83,10 @@ version_url = 'version/api_key/%%api_key%%'
|
|||
export_url = 'schedule/api_key/%%api_key%%/from/%%from%%/to/%%to%%'
|
||||
|
||||
# Update whether a schedule group has begun playing.
|
||||
update_item_url = 'notifyScheduleGroupPlay/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
|
||||
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
|
||||
|
||||
# Update whether an audio clip is currently playing.
|
||||
update_start_playing_url = 'notifyMediaItemStartPlay/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
|
||||
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
|
||||
|
||||
# ???
|
||||
generate_range_url = 'generate_range_dp.php'
|
||||
|
|
|
@ -13,33 +13,33 @@ handlers=consoleHandler,fileHandlerERROR,fileHandlerDEBUG
|
|||
|
||||
[logger_libs]
|
||||
handlers=nullHandler
|
||||
level=DEBUG
|
||||
level=CRITICAL
|
||||
qualname="process"
|
||||
propagate=0
|
||||
|
||||
[handler_consoleHandler]
|
||||
class=StreamHandler
|
||||
level=DEBUG
|
||||
level=CRITICAL
|
||||
formatter=simpleFormatter
|
||||
args=(sys.stdout,)
|
||||
|
||||
[handler_fileHandlerERROR]
|
||||
class=FileHandler
|
||||
level=WARNING
|
||||
level=CRITICAL
|
||||
formatter=simpleFormatter
|
||||
args=("./error.log",)
|
||||
args=("./error-unit-test.log",)
|
||||
|
||||
[handler_fileHandlerDEBUG]
|
||||
class=FileHandler
|
||||
level=DEBUG
|
||||
level=CRITICAL
|
||||
formatter=simpleFormatter
|
||||
args=("./debug.log",)
|
||||
args=("./debug-unit-test.log",)
|
||||
|
||||
[handler_nullHandler]
|
||||
class=FileHandler
|
||||
level=DEBUG
|
||||
level=CRITICAL
|
||||
formatter=simpleFormatter
|
||||
args=("./log_null.log",)
|
||||
args=("./log-null-unit-test.log",)
|
||||
|
||||
|
||||
[formatter_simpleFormatter]
|
||||
|
|
|
@ -45,6 +45,30 @@ class TestApiFunctions(unittest.TestCase):
|
|||
def test_is_server_compatible(self):
|
||||
self.assertTrue(self.api_client.is_server_compatible(False))
|
||||
|
||||
def test_get_schedule(self):
|
||||
status, response = self.api_client.get_schedule()
|
||||
self.assertTrue(response.has_key("status"))
|
||||
self.assertTrue(response.has_key("playlists"))
|
||||
self.assertTrue(response.has_key("check"))
|
||||
self.assertTrue(status == 1)
|
||||
|
||||
def test_get_media(self):
|
||||
self.assertTrue(True)
|
||||
|
||||
def test_notify_scheduled_item_start_playing(self):
|
||||
arr = dict()
|
||||
arr["x"] = dict()
|
||||
arr["x"]["schedule_id"]=1
|
||||
|
||||
response = self.api_client.notify_scheduled_item_start_playing("x", arr)
|
||||
self.assertTrue(response.has_key("status"))
|
||||
self.assertTrue(response.has_key("message"))
|
||||
|
||||
def test_notify_media_item_start_playing(self):
|
||||
response = self.api_client.notify_media_item_start_playing('{"schedule_id":1}', 5)
|
||||
self.assertTrue(response.has_key("status"))
|
||||
self.assertTrue(response.has_key("message"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -214,7 +214,7 @@ class Playout:
|
|||
|
||||
def get_schedule(self):
|
||||
logger = logging.getLogger()
|
||||
status, response = self.api_client.get_schedule();
|
||||
status, response = self.api_client.get_schedule()
|
||||
|
||||
if status == 1:
|
||||
logger.info("dump serialized schedule to %s", self.schedule_file)
|
||||
|
@ -498,7 +498,7 @@ class Playout:
|
|||
logger.error("%s", e)
|
||||
|
||||
# cue
|
||||
print "STARTIONG CUE"
|
||||
print "STARTING CUE"
|
||||
print self.cue_file.cue(dst_tmp, dst, float(media['cue_in']) / 1000, float(media['cue_out']) / 1000)
|
||||
print "END CUE"
|
||||
|
||||
|
|
Loading…
Reference in New Issue