diff --git a/airtime_mvc/application/common/PodcastManager.php b/airtime_mvc/application/common/PodcastManager.php index a090ff910..1e49463c1 100644 --- a/airtime_mvc/application/common/PodcastManager.php +++ b/airtime_mvc/application/common/PodcastManager.php @@ -37,6 +37,7 @@ class PodcastManager { // but will at least continue to ingest new episodes. if (!empty($episodes)) { $podcast->setDbAutoIngestTimestamp(gmdate('r', strtotime($episodes[0]->getDbPublicationDate())))->save(); + Logging::info($episodes); $service->downloadEpisodes($episodes); } } diff --git a/airtime_mvc/application/services/PodcastEpisodeService.php b/airtime_mvc/application/services/PodcastEpisodeService.php index 124290ac2..af61cdf61 100644 --- a/airtime_mvc/application/services/PodcastEpisodeService.php +++ b/airtime_mvc/application/services/PodcastEpisodeService.php @@ -46,7 +46,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir public function importEpisode($podcastId, $episode) { $e = $this->addPlaceholder($podcastId, $episode); $p = $e->getPodcast(); - $this->_download($e->getDbId(), $e->getDbDownloadUrl(), $p->getDbTitle(), $this->_getAlbumOverride($p)); + $this->_download($e->getDbId(), $e->getDbDownloadUrl(), $p->getDbTitle(), $this->_getAlbumOverride($p), $episode["title"]); return $e; } @@ -128,7 +128,8 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir /** @var PodcastEpisodes $episode */ foreach($episodes as $episode) { $podcast = $episode->getPodcast(); - $this->_download($episode->getDbId(), $episode->getDbDownloadUrl(), $podcast->getDbTitle(), $this->_getAlbumOverride($podcast)); + Logging::info($episode); + $this->_download($episode->getDbId(), $episode->getDbDownloadUrl(), $podcast->getDbTitle(), $this->_getAlbumOverride($podcast), $episode["title"]); } } @@ -158,7 +159,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir * @param string $title title of podcast to be downloaded - added as album to track metadata * @param boolean $album_override should we override the album name when downloading */ - private function _download($id, $url, $title, $album_override) { + private function _download($id, $url, $title, $album_override, $track_title = null) { $CC_CONFIG = Config::getConfig(); $stationUrl = Application_Common_HTTPHelper::getStationUrl(); $stationUrl .= substr($stationUrl, -1) == '/' ? '' : '/'; @@ -169,7 +170,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir 'api_key' => $CC_CONFIG["apiKey"][0], 'podcast_name' => $title, 'album_override' => $album_override, - ); + 'track_title' => $track_title); $task = $this->_executeTask(static::$_CELERY_TASKS[self::DOWNLOAD], $data); // Get the created ThirdPartyTaskReference and set the episode ID so // we can remove the placeholder if the import ends up stuck in a pending state diff --git a/python_apps/airtime-celery/airtime-celery/tasks.py b/python_apps/airtime-celery/airtime-celery/tasks.py index 3b06e89e5..32ac92be4 100644 --- a/python_apps/airtime-celery/airtime-celery/tasks.py +++ b/python_apps/airtime-celery/airtime-celery/tasks.py @@ -128,7 +128,7 @@ def soundcloud_delete(token, track_id): @celery.task(name='podcast-download', acks_late=True) -def podcast_download(id, url, callback_url, api_key, podcast_name, album_override): +def podcast_download(id, url, callback_url, api_key, podcast_name, album_override, track_title): """ Download a podcast episode @@ -138,6 +138,7 @@ def podcast_download(id, url, callback_url, api_key, podcast_name, album_overrid :param api_key: API key for callback authentication :param podcast_name: Name of podcast to be added to id3 metadata for smartblock :param album_override: Passing whether to override the album id3 even if it exists + :param track_title: Passing the title of the episode from feed to override the metadata :return: JSON formatted string of a dictionary of download statuses and file identifiers (for successful uploads) @@ -155,7 +156,7 @@ def podcast_download(id, url, callback_url, api_key, podcast_name, album_overrid shutil.copyfileobj(r.raw, audiofile) metadata_audiofile = mutagen.File(audiofile.name, easy=True) # replace album title as needed - metadata_audiofile = podcast_override_album(metadata_audiofile, podcast_name, album_override) + metadata_audiofile = podcast_override_metadata(metadata_audiofile, podcast_name, album_override, track_title) metadata_audiofile.save() filetypeinfo = metadata_audiofile.pprint() logger.info('filetypeinfo is {0}'.format(filetypeinfo.encode('ascii', 'ignore'))) @@ -171,7 +172,7 @@ def podcast_download(id, url, callback_url, api_key, podcast_name, album_overrid obj['status'] = 0 return json.dumps(obj) -def podcast_override_album(m, podcast_name, override): +def podcast_override_metadata(m, podcast_name, override, track_title): """ Override m['album'] if empty or forced with override arg """ @@ -179,6 +180,7 @@ def podcast_override_album(m, podcast_name, override): if override is True: logger.debug('overriding album name to {0} in podcast'.format(podcast_name.encode('ascii', 'ignore'))) m['album'] = podcast_name + m['title'] = track_title else: # replace the album id3 tag with the podcast name if the album tag is empty try: