Fix podcast episode ingest
This commit is contained in:
parent
40d0619f10
commit
a2d725f2b9
|
@ -6,7 +6,7 @@ class Rest_PodcastController extends Zend_Rest_Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Application_Service_PodcastService
|
* @var Application_Service_PodcastEpisodeService
|
||||||
*/
|
*/
|
||||||
protected $_service;
|
protected $_service;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class Rest_PodcastController extends Zend_Rest_Controller
|
||||||
// to prevent the user from trying to download them again while Celery is running
|
// to prevent the user from trying to download them again while Celery is running
|
||||||
$episodes = $this->_service->addPodcastEpisodePlaceholders($requestData["podcast"]["id"],
|
$episodes = $this->_service->addPodcastEpisodePlaceholders($requestData["podcast"]["id"],
|
||||||
$requestData["podcast"]["episodes"]);
|
$requestData["podcast"]["episodes"]);
|
||||||
//$this->_service->downloadEpisodes($episodes);
|
$this->_service->downloadEpisodes($episodes);
|
||||||
$podcast = Application_Service_PodcastService::updatePodcastFromArray($id, $requestData);
|
$podcast = Application_Service_PodcastService::updatePodcastFromArray($id, $requestData);
|
||||||
|
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
|
|
|
@ -194,15 +194,24 @@ class Application_Service_PodcastService
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function _generatePodcastArray($podcast, $rss) {
|
private static function _generatePodcastArray($podcast, $rss) {
|
||||||
$podcastArray = $podcast->toArray(BasePeer::TYPE_FIELDNAME);
|
$ingestedEpisodes = PodcastEpisodesQuery::create()
|
||||||
|
->findByDbPodcastId($podcast->getDbId());
|
||||||
|
$episodeIds = array();
|
||||||
|
foreach ($ingestedEpisodes as $e) {
|
||||||
|
array_push($episodeIds, $e->getDbEpisodeGuid());
|
||||||
|
}
|
||||||
|
|
||||||
|
$podcastArray = $podcast->toArray(BasePeer::TYPE_FIELDNAME);
|
||||||
$podcastArray["episodes"] = array();
|
$podcastArray["episodes"] = array();
|
||||||
foreach ($rss->get_items() as $item) {
|
foreach ($rss->get_items() as $item) {
|
||||||
/** @var SimplePie_Item $item */
|
/** @var SimplePie_Item $item */
|
||||||
array_push($podcastArray["episodes"], array(
|
array_push($podcastArray["episodes"], array(
|
||||||
"guid" => $item->get_id(),
|
"guid" => $item->get_id(),
|
||||||
|
"ingested" => in_array($item->get_id(), $episodeIds),
|
||||||
"title" => $item->get_title(),
|
"title" => $item->get_title(),
|
||||||
"author" => $item->get_author()->get_name(),
|
// From the RSS spec best practices:
|
||||||
|
// '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(),
|
"description" => $item->get_description(),
|
||||||
"pub_date" => $item->get_date("Y-m-d H:i:s"),
|
"pub_date" => $item->get_date("Y-m-d H:i:s"),
|
||||||
"link" => $item->get_link(),
|
"link" => $item->get_link(),
|
||||||
|
|
Loading…
Reference in New Issue