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 4a203cbf0..a2f100f5d 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) @@ -162,8 +163,9 @@ def podcast_download(id, url, callback_url, api_key, podcast_name, album_overrid # so we treat it like a mp3 if it has a mp3 file extension and hope for the best if filename.endswith(mp3suffix): metadata_audiofile = mutagen.mp3.MP3(audiofile.name, ID3=mutagen.easyid3.EasyID3) - #replace album title as needed - metadata_audiofile = podcast_override_album(metadata_audiofile, podcast_name, album_override) + #replace track metadata as indicated by album_override setting + # replace album title as needed + 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'))) @@ -179,7 +181,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 """ @@ -187,6 +189,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: