Pypo fixes and improvements
General: * Moved pypo author info into one file * Added two database columns in schedule table: "schedule_group_played" and "media_item_played". API clients: * Created get_liquidsoap_data() function which allows you to give arbitrary data to liquidsoap. * Added documentation * Renamed functions to make it more obvious what is happening pypo_cli: * Got rid of more constants that were not needed * Created function set_export_source() to reduce code repetition * Separated the downloading of the schedule from tracking what has been played. The tracking info is now kept in a separate file. This fixes the major bug that the playlist keeps restarting for the first minute of playback. * converted more print statements to debug statements pypoTester: * Now uses samples from the audio_samples directory, and schedules two audio clips back-to-back.
This commit is contained in:
parent
a138424451
commit
3613812012
20 changed files with 699 additions and 543 deletions
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../backend/StoredFile.php');
|
||||
|
||||
$api_key = $_GET['api_key'];
|
||||
|
@ -13,13 +12,6 @@ if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
|||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$filename = $_GET["file"];
|
||||
$file_id = substr($filename, 0, strpos($filename, "."));
|
||||
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
|
||||
|
|
37
api/notify_media_item_start_play.php
Normal file
37
api/notify_media_item_start_play.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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."));
|
||||
}
|
||||
?>
|
35
api/notify_schedule_group_play.php
Normal file
35
api/notify_schedule_group_play.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?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,6 +1,5 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../backend/Schedule.php');
|
||||
|
||||
$api_key = $_GET['api_key'];
|
||||
|
@ -13,12 +12,6 @@ if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
|||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$from = $_GET["from"];
|
||||
$to = $_GET["to"];
|
||||
echo Schedule::ExportRangeAsJson($from, $to);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue