Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jp jukebox activesong #1128

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Classes/ServiceAPI/MyRadio_Timeslot.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use DateTime;
use MyRadio\Config;
use MyRadio\iTones\iTones_Playlist;
use MyRadio\MyRadio\AuthUtils;
use MyRadio\MyRadioException;
use MyRadio\MyRadio\CoreUtils;
Expand Down Expand Up @@ -687,6 +688,8 @@ public static function getCurrentAndNext($time = null, $n = 1, $filter = [1])
$timeslot = self::getCurrentTimeslot($time, $filter);
$next = self::getNextTimeslot($time, $filter);

$currentJukebox = iTones_playlist::getPlaylistAtTime(date('H:i:s'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$currentJukebox = iTones_playlist::getPlaylistAtTime(date('H:i:s'));
$currentJukebox = iTones_Playlist::getPlaylistAtTime(date('H:i:s'));


//Still display a show if there's one scheduled for whatever reason.
if (empty($timeslot)) {
// Checking if it's term time according to the schedule is unreliable. Instead, check which selector source
Expand All @@ -704,7 +707,7 @@ public static function getCurrentAndNext($time = null, $n = 1, $filter = [1])
} else {
$response = [
'current' => [
'title' => Config::$short_name . ' Jukebox',
'title' => 'Jukebox: ' . $currentJukebox,
'desc' => 'There are currently no shows on right now, even our presenters
need a break. But it\'s okay, ' . Config::$short_name .
' Jukebox has got you covered, playing the best music for your ears!',
Expand Down Expand Up @@ -738,8 +741,10 @@ public static function getCurrentAndNext($time = null, $n = 1, $filter = [1])
//There's not a next show, but there might be one later
$nextshow = self::getNextTimeslot($lastnext->getEndTime(), $filter);

$nextJukebox = iTones_playlist::getPlaylistAtTime(date('H:i:s', ($lastnext->getEndTime()+90)));

$response['next'][] = [
'title' => Config::$short_name . ' Jukebox',
'title' => 'Jukebox: ' . $nextJukebox,
'desc' => 'There are currently no shows on right now, even our presenters
need a break. But it\'s okay, ' . Config::$short_name .
' Jukebox has got you covered, playing the best music for your ears!',
Expand Down
21 changes: 21 additions & 0 deletions src/Classes/iTones/iTones_Playlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,27 @@ public function getTitle()
return $this->title;
}

public function getPlaylistAtTime($time)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will this do if there are multiple active playlists at a time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return one of them. This shouldn't matter as we are planning to move to only having a single active playlist at any point.

{
$getplaylist = self::$db->fetchColumn(
'SELECT playlist.playlistid
FROM jukebox.playlists playlist
INNER JOIN jukebox.playlist_availability avail ON playlist.playlistid=avail.playlistid
WHERE playlist.category=2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a Config variable for the category ID? We'd rather not hard-code it if possible.

AND archived=false
AND avail.playlist_availability_id IN (
SELECT playlist_availability_id
FROM jukebox.playlist_timeslot
WHERE \''.$time.'\'
BETWEEN start_time
AND end_time

GROUP BY playlist_availability_id
)');
return $getplaylist[0];
//return $current_time;
}

/**
* Get the unique playlistid of the Playlist.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Menus/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
"url": "module=Mail,action=send,list=30",
"description": "Having a problem? Report it here and Computing and/or Engineering team will fix it for you. Or at least try."
},
{
"title": "Request a Song for the Music Library",
"url": "https://song-requests.ury.org.uk",
"description": "Want to play a song that's not in our library? Request it here and we'll (probably) buy it for you!"
},
{
"title": "Get Beds/Jingles",
"url": "https://docs.google.com/forms/d/e/1FAIpQLSdLauYhir0wRBHAJBXIw1OcpyRtdJulIueoVUz0CyM12qObSQ/viewform",
Expand Down