Bugfixes and more work on station podcast frontend
This commit is contained in:
parent
58a7b9324b
commit
e8980e7a79
9 changed files with 82 additions and 56 deletions
|
@ -50,12 +50,13 @@ class PodcastManager {
|
|||
$podcastArray = Application_Service_PodcastService::getPodcastById($podcast->getDbPodcastId());
|
||||
$episodeList = $podcastArray["episodes"];
|
||||
$episodes = array();
|
||||
// Sort the episodes by publication date to get the most recent
|
||||
usort($episodeList, array(static::class, "_sortByEpisodePubDate"));
|
||||
for ($i = 0; $i < sizeof($episodeList); $i++) {
|
||||
$episodeData = $episodeList[$i];
|
||||
$ingestTimestamp = $podcast->getDbAutoIngestTimestamp();
|
||||
// If the publication date of this episode is before the ingest timestamp, we don't need to ingest it
|
||||
// Since we're sorting by publication date, we can break
|
||||
if ($episodeData["pub_date"] < $ingestTimestamp) continue;
|
||||
if (strtotime($episodeData["pub_date"]) < strtotime($podcast->getDbAutoIngestTimestamp())) break;
|
||||
$episode = PodcastEpisodesQuery::create()->findOneByDbEpisodeGuid($episodeData["guid"]);
|
||||
// Make sure there's no existing episode placeholder or import, and that the data is non-empty
|
||||
if (empty($episode) && !empty($episodeData)) {
|
||||
|
|
|
@ -170,8 +170,12 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
|||
public function publish($fileId) {
|
||||
$id = Application_Model_Preference::getStationPodcastId();
|
||||
$url = $guid = Application_Common_HTTPHelper::getStationUrl()."rest/media/$fileId/download";
|
||||
$e = $this->_buildEpisode($id, $url, $guid, date('r'));
|
||||
$e->setDbFileId($fileId)->save();
|
||||
if (!PodcastEpisodesQuery::create()
|
||||
->filterByDbPodcastId($id)
|
||||
->findOneByDbFileId($fileId)) { // Don't allow duplicate episodes
|
||||
$e = $this->_buildEpisode($id, $url, $guid, date('r'));
|
||||
$e->setDbFileId($fileId)->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -220,11 +220,14 @@ class Application_Service_PodcastService
|
|||
* @return array
|
||||
*/
|
||||
private static function _generatePodcastArray($podcast, $rss) {
|
||||
$stationPodcast = StationPodcastQuery::create()->findOneByDbPodcastId($podcast->getDbId());
|
||||
$ingestedEpisodes = PodcastEpisodesQuery::create()
|
||||
->findByDbPodcastId($podcast->getDbId());
|
||||
$episodeIds = array();
|
||||
foreach ($ingestedEpisodes as $e) {
|
||||
array_push($episodeIds, $e->getDbEpisodeGuid());
|
||||
if (!$stationPodcast) {
|
||||
foreach ($ingestedEpisodes as $e) {
|
||||
array_push($episodeIds, $e->getDbEpisodeGuid());
|
||||
}
|
||||
}
|
||||
|
||||
$podcastArray = $podcast->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
|
@ -239,7 +242,7 @@ class Application_Service_PodcastService
|
|||
// 'An item's author element provides the e-mail address of the person who wrote the item'
|
||||
"author" => $item->get_author()->get_email(),
|
||||
"description" => $item->get_description(),
|
||||
"pub_date" => $item->get_date("Y-m-d H:i:s"),
|
||||
"pub_date" => $item->get_gmdate(),
|
||||
"link" => $item->get_link(),
|
||||
"enclosure" => $item->get_enclosure()
|
||||
));
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
<table id="podcast_episodes" class="datatable" cellpadding="0" cellspacing="0"></table>
|
||||
<table class="datatable podcast_episodes" cellpadding="0" cellspacing="0"></table>
|
||||
|
||||
<div class="btn-toolbar clearfix">
|
||||
<div class="btn-group pull-right">
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
<table id="podcast_episodes" class="datatable" cellpadding="0" cellspacing="0"></table>
|
||||
<table class="datatable podcast_episodes" cellpadding="0" cellspacing="0"></table>
|
||||
|
||||
<div class="btn-toolbar clearfix">
|
||||
<div class="btn-group pull-right">
|
||||
|
@ -36,7 +36,7 @@
|
|||
</button>
|
||||
</div>
|
||||
<div class='btn-group pull-right'>
|
||||
<button ng-click="savePodcast()" class="btn" title='<?php echo _("Save station podcast") ?>' type="button">
|
||||
<button ng-click="saveStationPodcast()" class="btn" title='<?php echo _("Save station podcast") ?>' type="button">
|
||||
<?php echo _("Save") ?>
|
||||
</button>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue