Merge pull request #28 from radiorabe/feature/robbt/podcast-naming

Podcast naming feature as per #26
This commit is contained in:
Robb 2017-03-06 18:12:57 -05:00 committed by GitHub
commit d86e223c45
3 changed files with 30 additions and 9 deletions

View file

@ -45,7 +45,8 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
*/
public function importEpisode($podcastId, $episode) {
$e = $this->addPlaceholder($podcastId, $episode);
$this->_download($e->getDbId(), $e->getDbDownloadUrl());
$p = $e->getPodcast();
$this->_download($e->getDbId(), $e->getDbDownloadUrl(), $p->getDbTitle());
return $e;
}
@ -126,7 +127,8 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
public function downloadEpisodes($episodes) {
/** @var PodcastEpisodes $episode */
foreach($episodes as $episode) {
$this->_download($episode->getDbId(), $episode->getDbDownloadUrl());
$podcast = $episode->getPodcast();
$this->_download($episode->getDbId(), $episode->getDbDownloadUrl(), $podcast->getDbTitle());
}
}
@ -136,8 +138,9 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
*
* @param int $id episode unique ID
* @param string $url download url for the episode
* @param string $title title of podcast to be downloaded - added as album to track metadata
*/
private function _download($id, $url) {
private function _download($id, $url, $title) {
$CC_CONFIG = Config::getConfig();
$stationUrl = Application_Common_HTTPHelper::getStationUrl();
$stationUrl .= substr($stationUrl, -1) == '/' ? '' : '/';
@ -146,6 +149,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
'url' => $url,
'callback_url' => $stationUrl . 'rest/media',
'api_key' => $CC_CONFIG["apiKey"][0],
'podcast_name' => $title,
);
$task = $this->_executeTask(static::$_CELERY_TASKS[self::DOWNLOAD], $data);
// Get the created ThirdPartyTaskReference and set the episode ID so
@ -436,4 +440,4 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
}
}
}
}

View file

@ -91,8 +91,7 @@ class Application_Service_PodcastService
$podcastArray["language"] = htmlspecialchars($rss->get_language());
$podcastArray["copyright"] = htmlspecialchars($rss->get_copyright());
$rssAuthor = $rss->getAuthor();
$name = empty($rssAuthor) ? "" : $rss->rssAuthor->get_name();
$name = empty($rss->get_author()) ? "" : $rss->get_author()->get_name();
$podcastArray["creator"] = htmlspecialchars($name);
$categories = array();
@ -471,4 +470,4 @@ class Application_Service_PodcastService
return false;
}
}
}
}