cc-3476: dynamic timeout
This commit is contained in:
parent
c301cd5256
commit
1a4e6c563b
2 changed files with 75 additions and 123 deletions
|
@ -676,102 +676,6 @@ class Application_Model_Schedule {
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the schedule in json formatted for pypo (the liquidsoap scheduler)
|
||||
*
|
||||
* @param string $p_fromDateTime
|
||||
* In the format "YYYY-MM-DD-HH-mm-SS"
|
||||
* @param string $p_toDateTime
|
||||
* In the format "YYYY-MM-DD-HH-mm-SS"
|
||||
*/
|
||||
public static function GetScheduledPlaylistsOld($p_fromDateTime = null, $p_toDateTime = null)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
if (is_null($p_fromDateTime)) {
|
||||
$t1 = new DateTime("@".time());
|
||||
$range_start = $t1->format("Y-m-d H:i:s");
|
||||
} else {
|
||||
$range_start = Application_Model_Schedule::PypoTimeToAirtimeTime($p_fromDateTime);
|
||||
}
|
||||
if (is_null($p_fromDateTime)) {
|
||||
$t2 = new DateTime("@".time());
|
||||
$t2->add(new DateInterval("PT24H"));
|
||||
$range_end = $t2->format("Y-m-d H:i:s");
|
||||
} else {
|
||||
$range_end = Application_Model_Schedule::PypoTimeToAirtimeTime($p_toDateTime);
|
||||
}
|
||||
|
||||
// Scheduler wants everything in a playlist
|
||||
$data = Application_Model_Schedule::GetItems($range_start, $range_end, true);
|
||||
$playlists = array();
|
||||
|
||||
if (is_array($data)){
|
||||
foreach ($data as $dx){
|
||||
$start = $dx['start'];
|
||||
|
||||
//chop off subseconds
|
||||
$start = substr($start, 0, 19);
|
||||
|
||||
//Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
|
||||
$pkey = Application_Model_Schedule::AirtimeTimeToPypoTime($start);
|
||||
$timestamp = strtotime($start);
|
||||
$playlists[$pkey]['source'] = "PLAYLIST";
|
||||
$playlists[$pkey]['x_ident'] = $dx['group_id'];
|
||||
$playlists[$pkey]['timestamp'] = $timestamp;
|
||||
$playlists[$pkey]['duration'] = $dx['clip_length'];
|
||||
$playlists[$pkey]['played'] = '0';
|
||||
$playlists[$pkey]['schedule_id'] = $dx['group_id'];
|
||||
$playlists[$pkey]['show_name'] = $dx['show_name'];
|
||||
$playlists[$pkey]['show_start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($dx['show_start']);
|
||||
$playlists[$pkey]['show_end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($dx['show_end']);
|
||||
$playlists[$pkey]['user_id'] = 0;
|
||||
$playlists[$pkey]['id'] = $dx['group_id'];
|
||||
$playlists[$pkey]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($dx["start"]);
|
||||
$playlists[$pkey]['end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($dx["end"]);
|
||||
}
|
||||
}
|
||||
ksort($playlists);
|
||||
|
||||
foreach ($playlists as &$playlist)
|
||||
{
|
||||
$scheduleGroup = new Application_Model_ScheduleGroup($playlist["schedule_id"]);
|
||||
$items = $scheduleGroup->getItems();
|
||||
$medias = array();
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$storedFile = Application_Model_StoredFile::Recall($item["file_id"]);
|
||||
$uri = $storedFile->getFileUrlUsingConfigAddress();
|
||||
|
||||
$starts = Application_Model_Schedule::AirtimeTimeToPypoTime($item["starts"]);
|
||||
$medias[$starts] = array(
|
||||
'id' => $storedFile->getGunid(),
|
||||
'uri' => $uri,
|
||||
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),
|
||||
'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]),
|
||||
'fade_cross' => 0,
|
||||
'cue_in' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_in"]),
|
||||
'cue_out' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_out"]),
|
||||
'start' => $starts,
|
||||
'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["ends"])
|
||||
);
|
||||
}
|
||||
ksort($medias);
|
||||
$playlist['medias'] = $medias;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['status'] = array('range' => array('start' => $range_start, 'end' => $range_end),
|
||||
'version' => AIRTIME_REST_VERSION);
|
||||
$result['playlists'] = $playlists;
|
||||
$result['check'] = 1;
|
||||
$result['stream_metadata'] = array();
|
||||
$result['stream_metadata']['format'] = Application_Model_Preference::GetStreamLabelFormat();
|
||||
$result['stream_metadata']['station_name'] = Application_Model_Preference::GetStationName();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function deleteAll()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue