refactored autoplaylist and updated showinstance to make sequential adds possible
This commit is contained in:
parent
8de94a670f
commit
6f7c2f2cc9
|
@ -23,58 +23,44 @@ class AutoPlaylistManager {
|
|||
*
|
||||
*/
|
||||
public static function buildAutoPlaylist() {
|
||||
Logging::info("Checking to run Auto Playlist");
|
||||
//Logging::info("Checking to run Auto Playlist");
|
||||
$autoPlaylists = static::_upcomingAutoPlaylistShows();
|
||||
foreach ($autoPlaylists as $autoplaylist) {
|
||||
// creates a ShowInstance object to build the playlist in from the ShowInstancesQuery Object
|
||||
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
||||
$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
|
||||
$sid = $si->getShowId();
|
||||
$playlistrepeat = new Application_Model_Show($sid);
|
||||
$introplaylistid = Application_Model_Preference::GetIntroPlaylist();
|
||||
Logging::info("intro");
|
||||
Logging::info($introplaylistid);
|
||||
Logging::info($playlistid);
|
||||
Logging::info("outro");
|
||||
$outroplaylistid = Application_Model_Preference::GetOutroPlaylist();
|
||||
Logging::info($outroplaylistid);
|
||||
|
||||
if ($playlistrepeat->getAutoPlaylistRepeat()) {
|
||||
$full = false;
|
||||
while(!$full) {
|
||||
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
||||
$ps = $si->getPercentScheduled();
|
||||
if ($introplaylistid != null) {
|
||||
sleep(20);
|
||||
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 {
|
||||
// we want to check and see if we need to repeat this process until the show is 100% scheduled
|
||||
// so we create a while loop and break it immediately if repeat until full isn't enabled
|
||||
// otherwise we continue to go through adding playlists, including the intro and outro if enabled
|
||||
$full = false;
|
||||
$repeatuntilfull = $playlistrepeat->getAutoPlaylistRepeat();
|
||||
while(!$full) {
|
||||
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
||||
$si->addPlaylistToShow($playlistid, false);
|
||||
$ps = $si->getPercentScheduled();
|
||||
//Logging::info($ps);
|
||||
if ($introplaylistid != null) {
|
||||
sleep(20);
|
||||
Logging::info('adding intro');
|
||||
//Logging::info('adding intro');
|
||||
$si->addPlaylistToShowStart($introplaylistid, false);
|
||||
}
|
||||
if ($outroplaylistid != null) {
|
||||
sleep(20);
|
||||
Logging::info('adding outro');
|
||||
//Logging::info('adding outro');
|
||||
$si->addPlaylistToShow($outroplaylistid, false);
|
||||
//Logging::info("The total percent scheduled is % $ps");
|
||||
}
|
||||
if ($ps > 100) {
|
||||
$full = true;
|
||||
}
|
||||
elseif (!$repeatuntilfull) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
$si->setAutoPlaylistBuilt(true);
|
||||
|
||||
|
|
|
@ -242,6 +242,9 @@ SQL;
|
|||
array(array("id" => $lastid, "instance" => $id, "timestamp" => $ts)),
|
||||
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" => $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…
Reference in New Issue