refactored autoplaylist and updated showinstance to make sequential adds possible
This commit is contained in:
parent
8de94a670f
commit
6f7c2f2cc9
2 changed files with 26 additions and 34 deletions
|
@ -23,58 +23,44 @@ class AutoPlaylistManager {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function buildAutoPlaylist() {
|
public static function buildAutoPlaylist() {
|
||||||
Logging::info("Checking to run Auto Playlist");
|
//Logging::info("Checking to run Auto Playlist");
|
||||||
$autoPlaylists = static::_upcomingAutoPlaylistShows();
|
$autoPlaylists = static::_upcomingAutoPlaylistShows();
|
||||||
foreach ($autoPlaylists as $autoplaylist) {
|
foreach ($autoPlaylists as $autoplaylist) {
|
||||||
// creates a ShowInstance object to build the playlist in from the ShowInstancesQuery Object
|
// creates a ShowInstance object to build the playlist in from the ShowInstancesQuery Object
|
||||||
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
||||||
$playlistid = $si->GetAutoPlaylistId();
|
$playlistid = $si->GetAutoPlaylistId();
|
||||||
Logging::info("Scheduling $playlistid");
|
|
||||||
// call the addPlaylist to show function and don't check for user permission to avoid call to non-existant user object
|
// call the addPlaylist to show function and don't check for user permission to avoid call to non-existant user object
|
||||||
$sid = $si->getShowId();
|
$sid = $si->getShowId();
|
||||||
$playlistrepeat = new Application_Model_Show($sid);
|
$playlistrepeat = new Application_Model_Show($sid);
|
||||||
$introplaylistid = Application_Model_Preference::GetIntroPlaylist();
|
$introplaylistid = Application_Model_Preference::GetIntroPlaylist();
|
||||||
Logging::info("intro");
|
|
||||||
Logging::info($introplaylistid);
|
|
||||||
Logging::info($playlistid);
|
|
||||||
Logging::info("outro");
|
|
||||||
$outroplaylistid = Application_Model_Preference::GetOutroPlaylist();
|
$outroplaylistid = Application_Model_Preference::GetOutroPlaylist();
|
||||||
Logging::info($outroplaylistid);
|
|
||||||
|
|
||||||
if ($playlistrepeat->getAutoPlaylistRepeat()) {
|
// we want to check and see if we need to repeat this process until the show is 100% scheduled
|
||||||
$full = false;
|
// so we create a while loop and break it immediately if repeat until full isn't enabled
|
||||||
while(!$full) {
|
// otherwise we continue to go through adding playlists, including the intro and outro if enabled
|
||||||
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
$full = false;
|
||||||
$ps = $si->getPercentScheduled();
|
$repeatuntilfull = $playlistrepeat->getAutoPlaylistRepeat();
|
||||||
if ($introplaylistid != null) {
|
while(!$full) {
|
||||||
sleep(20);
|
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
||||||
Logging::info('adding intro');
|
|
||||||
$si->addPlaylistToShowStart($introplaylistid, false);
|
|
||||||
}
|
|
||||||
if ($outroplaylistid != null) {
|
|
||||||
sleep(20);
|
|
||||||
Logging::info('adding outro');
|
|
||||||
$si->addPlaylistToShow($outroplaylistid, false);
|
|
||||||
//Logging::info("The total percent scheduled is % $ps");
|
|
||||||
}
|
|
||||||
if ($ps > 100) {
|
|
||||||
$full = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$si->addPlaylistToShow($playlistid, false);
|
$si->addPlaylistToShow($playlistid, false);
|
||||||
|
$ps = $si->getPercentScheduled();
|
||||||
|
//Logging::info($ps);
|
||||||
if ($introplaylistid != null) {
|
if ($introplaylistid != null) {
|
||||||
sleep(20);
|
//Logging::info('adding intro');
|
||||||
Logging::info('adding intro');
|
|
||||||
$si->addPlaylistToShowStart($introplaylistid, false);
|
$si->addPlaylistToShowStart($introplaylistid, false);
|
||||||
}
|
}
|
||||||
if ($outroplaylistid != null) {
|
if ($outroplaylistid != null) {
|
||||||
sleep(20);
|
//Logging::info('adding outro');
|
||||||
Logging::info('adding outro');
|
|
||||||
$si->addPlaylistToShow($outroplaylistid, false);
|
$si->addPlaylistToShow($outroplaylistid, false);
|
||||||
|
//Logging::info("The total percent scheduled is % $ps");
|
||||||
}
|
}
|
||||||
|
if ($ps > 100) {
|
||||||
|
$full = true;
|
||||||
|
}
|
||||||
|
elseif (!$repeatuntilfull) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$si->setAutoPlaylistBuilt(true);
|
$si->setAutoPlaylistBuilt(true);
|
||||||
|
|
||||||
|
|
|
@ -242,6 +242,9 @@ SQL;
|
||||||
array(array("id" => $lastid, "instance" => $id, "timestamp" => $ts)),
|
array(array("id" => $lastid, "instance" => $id, "timestamp" => $ts)),
|
||||||
array(array("id" => $pl_id, "type" => "playlist"))
|
array(array("id" => $pl_id, "type" => "playlist"))
|
||||||
);
|
);
|
||||||
|
// doing this to update the database schedule so that subsequent adds will work.
|
||||||
|
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
|
||||||
|
$this->_showInstance->updateScheduleStatus($con);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -259,6 +262,9 @@ SQL;
|
||||||
array(array("id" => 0, "instance" => $id, "timestamp" => $ts)),
|
array(array("id" => 0, "instance" => $id, "timestamp" => $ts)),
|
||||||
array(array("id" => $pl_id, "type" => "playlist"))
|
array(array("id" => $pl_id, "type" => "playlist"))
|
||||||
);
|
);
|
||||||
|
// doing this to update the database schedule so that subsequent adds will work.
|
||||||
|
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
|
||||||
|
$this->_showInstance->updateScheduleStatus($con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue