mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-25 10:27:06 +00:00
Make overnight playlists check the start date, because that makes way more sense.
This commit is contained in:
parent
04606cb776
commit
cb91a731c1
|
@ -110,15 +110,6 @@ class PlaylistsController
|
|||
|
||||
if (date('Gi', $end) < date('Gi', $start)) {
|
||||
// Overnight playlist - Create two "events"
|
||||
$schedule[] = [
|
||||
'name' => $playlist->getName(),
|
||||
'day' => $day_name,
|
||||
'start_hour' => 0,
|
||||
'start_min' => 0,
|
||||
'end_hour' => (int)date('G', $end),
|
||||
'end_min' => (int)date('i', $end),
|
||||
'options' => $schedule_options,
|
||||
];
|
||||
$schedule[] = [
|
||||
'name' => $playlist->getName(),
|
||||
'day' => $day_name,
|
||||
|
@ -128,6 +119,18 @@ class PlaylistsController
|
|||
'end_min' => 59,
|
||||
'options' => $schedule_options,
|
||||
];
|
||||
|
||||
$next_day = ($day_key == 7) ? $schedule_days[1] : $schedule_days[$day_key+1];
|
||||
|
||||
$schedule[] = [
|
||||
'name' => $playlist->getName(),
|
||||
'day' => $next_day,
|
||||
'start_hour' => 0,
|
||||
'start_min' => 0,
|
||||
'end_hour' => (int)date('G', $end),
|
||||
'end_min' => (int)date('i', $end),
|
||||
'options' => $schedule_options,
|
||||
];
|
||||
} else {
|
||||
// Normal playlist
|
||||
$schedule[] = [
|
||||
|
|
|
@ -308,21 +308,26 @@ class StationPlaylist
|
|||
*/
|
||||
public function canPlayScheduled(): bool
|
||||
{
|
||||
$is_overnight = ($this->getScheduleEndTime() < $this->getScheduleStartTime());
|
||||
|
||||
$play_once_days = $this->getScheduleDays();
|
||||
|
||||
if (!empty($play_once_days) && !in_array(gmdate('N'), $play_once_days)) {
|
||||
$day_to_check = gmdate('N');
|
||||
if ($is_overnight) {
|
||||
$day_to_check = ($day_to_check == 1) ? 7 : $day_to_check - 1;
|
||||
}
|
||||
|
||||
if (!empty($play_once_days) && !in_array($day_to_check, $play_once_days)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$current_timecode = self::getCurrentTimeCode();
|
||||
|
||||
if ($this->getScheduleEndTime() < $this->getScheduleStartTime()) {
|
||||
// Overnight playlist
|
||||
if ($is_overnight) {
|
||||
return ($current_timecode >= $this->getScheduleStartTime() || $current_timecode <= $this->getScheduleEndTime());
|
||||
} else {
|
||||
// Normal playlist
|
||||
return ($current_timecode >= $this->getScheduleStartTime() && $current_timecode <= $this->getScheduleEndTime());
|
||||
}
|
||||
|
||||
return ($current_timecode >= $this->getScheduleStartTime() && $current_timecode <= $this->getScheduleEndTime());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user