Merge pull request #1 from LibreTime/master

catch up to main repo
This commit is contained in:
mikeopensauce 2019-02-16 11:28:55 +00:00 committed by GitHub
commit fd97b5744a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 95 additions and 23 deletions

View File

@ -23,32 +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();
$outroplaylistid = Application_Model_Preference::GetOutroPlaylist();
if ($playlistrepeat->getAutoPlaylistRepeat()) {
$full = false;
while(!$full) {
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
$si->addPlaylistToShow($playlistid, false);
$ps = $si->getPercentScheduled();
//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) {
//Logging::info('adding intro');
$si->addPlaylistToShowStart($introplaylistid, false);
}
if ($outroplaylistid != null) {
//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);

View File

@ -47,6 +47,8 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetDefaultFadeOut($values["stationDefaultFadeOut"]);
Application_Model_Preference::SetPodcastAlbumOverride($values["podcastAlbumOverride"]);
Application_Model_Preference::SetPodcastAutoSmartblock($values["podcastAutoSmartblock"]);
Application_Model_Preference::SetIntroPlaylist($values["introPlaylistSelect"]);
Application_Model_Preference::SetOutroPlaylist($values["outroPlaylistSelect"]);
Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]);
Application_Model_Preference::SetAllowedCorsUrls($values["allowedCorsUrls"]);
Application_Model_Preference::SetDefaultLocale($values["locale"]);

View File

@ -101,6 +101,21 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
));
// add intro playlist select here
$introPlaylistSelect = new Zend_Form_Element_Select("introPlaylistSelect");
$introPlaylistSelect->setLabel(_("Intro Autoloading Playlist"));
$introPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames(true));
$introPlaylistSelect->setValue(Application_Model_Preference::GetIntroPlaylist());
$this->addElement($introPlaylistSelect);
$outroPlaylistSelect = new Zend_Form_Element_Select("outroPlaylistSelect");
$outroPlaylistSelect->setLabel(_("Outro Autoloading Playlist"));
$outroPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames(true));
$outroPlaylistSelect->setValue(Application_Model_Preference::GetOutroPlaylist());
$this->addElement($outroPlaylistSelect);
$podcast_album_override = new Zend_Form_Element_Radio('podcastAlbumOverride');
$podcast_album_override->setLabel(_('Podcast Metadata Override'));
$podcast_album_override->setMultiOptions(array(

View File

@ -1776,7 +1776,6 @@ SQL;
// construct limit restriction
$limits = array();
if (isset($storedCrit['limit'])) {
if ($storedCrit['limit']['modifier'] == "items") {
$limits['time'] = 1440 * 60;

View File

@ -387,6 +387,26 @@ class Application_Model_Preference
return $val === '1' ? true : false;
}
public static function GetIntroPlaylist()
{
return self::getValue("intro_playlist");
}
public static function GetOutroPlaylist()
{
return self::getValue("outro_playlist");
}
public static function SetIntroPlaylist($playlist)
{
self::setValue("intro_playlist", $playlist);
}
public static function SetOutroPlaylist($playlist)
{
self::setValue("outro_playlist", $playlist);
}
public static function SetPhone($phone)
{

View File

@ -214,7 +214,6 @@ final class Application_Model_Scheduler
private function retrieveMediaFiles($id, $type, $show)
{
$files = array();
if ($type === "audioclip") {
$file = CcFilesQuery::create()->findPK($id, $this->con);

View File

@ -242,9 +242,30 @@ 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);
}
/**
* Add a playlist as the first item of the current show.
*
* @param int $plId
* Playlist ID.
*/
public function addPlaylistToShowStart($pl_id, $checkUserPerm = true)
{
$ts = intval($this->_showInstance->getDbLastScheduled("U")) ? : 0;
$id = $this->_showInstance->getDbId();
$scheduler = new Application_Model_Scheduler($checkUserPerm);
$scheduler->scheduleAfter(
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);
}
/**

View File

@ -31,6 +31,10 @@
<?php echo $this->element->getElement('stationDefaultCrossfadeDuration')->render() ?>
<?php echo $this->element->getElement('introPlaylistSelect')->render() ?>
<?php echo $this->element->getElement('outroPlaylistSelect')->render() ?>
<?php echo $this->element->getElement('podcastAlbumOverride')->render() ?>
<?php echo $this->element->getElement('podcastAutoSmartblock')->render() ?>

View File

@ -580,7 +580,7 @@ var AIRTIME = (function(AIRTIME) {
///* Is Playlist */ { "sTitle" : $.i18n._("Playlist / Block") , "mDataProp" : "is_playlist" , "bSearchable" : false , "sWidth" : "110px" , "sClass" : "library_is_playlist"} ,
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "track_title" , "sClass" : "library_title" , "sWidth" : "170px" },
/* Creator */ { "sTitle" : $.i18n._("Creator") , "mDataProp" : "artist_name" , "sClass" : "library_creator" , "sWidth" : "160px" },
/* Album */ { "sTitle" : $.i18n._("Album") , "mDataProp" : "album_title" , "sClass" : "library_album" , "sWidth" : "150px" },
/* Album */ { "sTitle" : $.i18n._("Album") , "mDataProp" : "album_title" , "bVisible" : false , "sClass" : "library_album" , "sWidth" : "150px" },
/* Bit Rate */ { "sTitle" : $.i18n._("Bit Rate") , "mDataProp" : "bit_rate" , "bVisible" : false , "sClass" : "library_bitrate" , "sWidth" : "80px" },
/* BPM */ { "sTitle" : $.i18n._("BPM") , "mDataProp" : "bpm" , "bVisible" : false , "sClass" : "library_bpm" , "sWidth" : "50px" },
/* Composer */ { "sTitle" : $.i18n._("Composer") , "mDataProp" : "composer" , "bVisible" : false , "sClass" : "library_composer" , "sWidth" : "150px" },
@ -590,7 +590,7 @@ var AIRTIME = (function(AIRTIME) {
/* Cue Out */ { "sTitle" : $.i18n._("Cue Out") , "mDataProp" : "cueout" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "description" , "bVisible" : false , "sClass" : "library_description" , "sWidth" : "150px" },
/* Encoded */ { "sTitle" : $.i18n._("Encoded By") , "mDataProp" : "encoded_by" , "bVisible" : false , "sClass" : "library_encoded" , "sWidth" : "150px" },
/* Genre */ { "sTitle" : $.i18n._("Genre") , "mDataProp" : "genre" , "bVisible" : false , "sClass" : "library_genre" , "sWidth" : "100px" },
/* Genre */ { "sTitle" : $.i18n._("Genre") , "mDataProp" : "genre" , "sClass" : "library_genre" , "sWidth" : "100px" },
/* ISRC Number */ { "sTitle" : $.i18n._("ISRC") , "mDataProp" : "isrc_number" , "bVisible" : false , "sClass" : "library_isrc" , "sWidth" : "150px" },
/* Label */ { "sTitle" : $.i18n._("Label") , "mDataProp" : "label" , "bVisible" : false , "sClass" : "library_label" , "sWidth" : "125px" },
/* Language */ { "sTitle" : $.i18n._("Language") , "mDataProp" : "language" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" },
@ -603,7 +603,7 @@ var AIRTIME = (function(AIRTIME) {
/* Replay Gain */ { "sTitle" : $.i18n._("Replay Gain") , "mDataProp" : "replay_gain" , "bVisible" : false , "sClass" : "library_replay_gain" , "sWidth" : "125px" },
/* Sample Rate */ { "sTitle" : $.i18n._("Sample Rate") , "mDataProp" : "sample_rate" , "bVisible" : false , "sClass" : "library_sr" , "sWidth" : "125px" },
/* Track Number */ { "sTitle" : $.i18n._("Track Number") , "mDataProp" : "track_number" , "bVisible" : false , "sClass" : "library_track" , "sWidth" : "125px" },
/* Upload Time */ { "sTitle" : $.i18n._("Uploaded") , "mDataProp" : "utime" , "bVisible" : false , "sClass" : "library_upload_time" , "sWidth" : "155px" },
/* Upload Time */ { "sTitle" : $.i18n._("Uploaded") , "mDataProp" : "utime" , "sClass" : "library_upload_time" , "sWidth" : "155px" },
/* Website */ { "sTitle" : $.i18n._("Website") , "mDataProp" : "info_url" , "bVisible" : false , "sClass" : "library_url" , "sWidth" : "150px" },
/* Year */ { "sTitle" : $.i18n._("Year") , "mDataProp" : "year" , "bVisible" : false , "sClass" : "library_year" , "sWidth" : "60px" }
];
@ -794,7 +794,7 @@ var AIRTIME = (function(AIRTIME) {
},
"fnDrawCallback": AIRTIME.library.fnDrawCallback,
"aaSorting": [[5, 'asc']],
"aaSorting": [[29, 'desc']],
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"bAutoWidth": false,