CC-1985 : Automatic rebroadcast of recorded content
scheduling the recorded file in any rebroadcast shows.
This commit is contained in:
parent
864cda6c34
commit
fae71ed051
5 changed files with 39 additions and 56 deletions
|
@ -24,41 +24,6 @@ class ScheduleGroup {
|
|||
return $result != "0";
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a date to an ID by stripping out all characters
|
||||
* and padding with zeros.
|
||||
*
|
||||
* @param string $p_dateStr
|
||||
*/
|
||||
public static function dateToId($p_dateStr) {
|
||||
$p_dateStr = str_replace(":", "", $p_dateStr);
|
||||
$p_dateStr = str_replace(" ", "", $p_dateStr);
|
||||
$p_dateStr = str_replace(".", "", $p_dateStr);
|
||||
$p_dateStr = str_replace("-", "", $p_dateStr);
|
||||
$p_dateStr = substr($p_dateStr, 0, 17);
|
||||
$p_dateStr = str_pad($p_dateStr, 17, "0");
|
||||
return $p_dateStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the two times together, return the result.
|
||||
*
|
||||
* @param string $p_baseTime
|
||||
* Specified as YYYY-MM-DD HH:MM:SS
|
||||
*
|
||||
* @param string $p_addTime
|
||||
* Specified as HH:MM:SS.nnnnnn
|
||||
*
|
||||
* @return string
|
||||
* The end time, to the nearest second.
|
||||
*/
|
||||
// protected function calculateEndTime($p_startTime, $p_trackTime) {
|
||||
// $p_trackTime = substr($p_startTime, 0, );
|
||||
// $start = new DateTime();
|
||||
// $interval = new DateInterval()
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Add a music clip or playlist to the schedule.
|
||||
*
|
||||
|
@ -77,6 +42,7 @@ class ScheduleGroup {
|
|||
*/
|
||||
public function add($show_instance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
if (!is_null($p_audioFileId)) {
|
||||
// Schedule a single audio track
|
||||
|
||||
|
@ -92,19 +58,16 @@ class ScheduleGroup {
|
|||
if (empty($length)) {
|
||||
return new PEAR_Error("Length is empty.");
|
||||
}
|
||||
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
|
||||
return new PEAR_Error("Schedule conflict.", 555);
|
||||
}
|
||||
|
||||
|
||||
// Insert into the table
|
||||
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
|
||||
$id = $this->dateToId($p_datetime);
|
||||
|
||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||
." (playlist_id, starts, ends, clip_length, group_id, file_id)"
|
||||
." VALUES (0, TIMESTAMP '$p_datetime', "
|
||||
." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)"
|
||||
." VALUES ($show_instance, TIMESTAMP '$p_datetime', "
|
||||
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
|
||||
." '$length',"
|
||||
." {$this->groupId}, $p_audioFileId)";
|
||||
." {$this->groupId}, $p_audioFileId, '$length')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
//var_dump($sql);
|
||||
|
@ -112,7 +75,8 @@ class ScheduleGroup {
|
|||
}
|
||||
return $this->groupId;
|
||||
|
||||
} elseif (!is_null($p_playlistId)){
|
||||
}
|
||||
elseif (!is_null($p_playlistId)){
|
||||
// Schedule a whole playlist
|
||||
|
||||
// Load existing playlist
|
||||
|
@ -130,7 +94,6 @@ class ScheduleGroup {
|
|||
|
||||
// Insert all items into the schedule
|
||||
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
|
||||
$id = $this->dateToId($p_datetime);
|
||||
$itemStartTime = $p_datetime;
|
||||
|
||||
$plItems = $playlist->getContents();
|
||||
|
@ -157,7 +120,7 @@ class ScheduleGroup {
|
|||
}
|
||||
}
|
||||
|
||||
public function addAfter($show_instance, $p_groupId, $p_audioFileId) {
|
||||
public function addFileAfter($show_instance, $p_groupId, $p_audioFileId) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// Get the end time for the given entry
|
||||
$sql = "SELECT MAX(ends) FROM ".$CC_CONFIG["scheduleTable"]
|
||||
|
@ -176,10 +139,6 @@ class ScheduleGroup {
|
|||
return $this->add($show_instance, $startTime, null, $p_playlistId);
|
||||
}
|
||||
|
||||
public function update() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the group from the schedule.
|
||||
* Note: does not check if it is in the past, you can remove anything.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue