merge in audiofile fix from master
This commit is contained in:
commit
e773887736
|
@ -37,6 +37,7 @@ class PodcastManager {
|
||||||
// but will at least continue to ingest new episodes.
|
// but will at least continue to ingest new episodes.
|
||||||
if (!empty($episodes)) {
|
if (!empty($episodes)) {
|
||||||
$podcast->setDbAutoIngestTimestamp(gmdate('r', strtotime($episodes[0]->getDbPublicationDate())))->save();
|
$podcast->setDbAutoIngestTimestamp(gmdate('r', strtotime($episodes[0]->getDbPublicationDate())))->save();
|
||||||
|
Logging::info($episodes);
|
||||||
$service->downloadEpisodes($episodes);
|
$service->downloadEpisodes($episodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
||||||
public function importEpisode($podcastId, $episode) {
|
public function importEpisode($podcastId, $episode) {
|
||||||
$e = $this->addPlaceholder($podcastId, $episode);
|
$e = $this->addPlaceholder($podcastId, $episode);
|
||||||
$p = $e->getPodcast();
|
$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;
|
return $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,8 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
||||||
/** @var PodcastEpisodes $episode */
|
/** @var PodcastEpisodes $episode */
|
||||||
foreach($episodes as $episode) {
|
foreach($episodes as $episode) {
|
||||||
$podcast = $episode->getPodcast();
|
$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 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
|
* @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();
|
$CC_CONFIG = Config::getConfig();
|
||||||
$stationUrl = Application_Common_HTTPHelper::getStationUrl();
|
$stationUrl = Application_Common_HTTPHelper::getStationUrl();
|
||||||
$stationUrl .= substr($stationUrl, -1) == '/' ? '' : '/';
|
$stationUrl .= substr($stationUrl, -1) == '/' ? '' : '/';
|
||||||
|
@ -169,7 +170,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
||||||
'api_key' => $CC_CONFIG["apiKey"][0],
|
'api_key' => $CC_CONFIG["apiKey"][0],
|
||||||
'podcast_name' => $title,
|
'podcast_name' => $title,
|
||||||
'album_override' => $album_override,
|
'album_override' => $album_override,
|
||||||
);
|
'track_title' => $track_title);
|
||||||
$task = $this->_executeTask(static::$_CELERY_TASKS[self::DOWNLOAD], $data);
|
$task = $this->_executeTask(static::$_CELERY_TASKS[self::DOWNLOAD], $data);
|
||||||
// Get the created ThirdPartyTaskReference and set the episode ID so
|
// 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
|
// we can remove the placeholder if the import ends up stuck in a pending state
|
||||||
|
|
|
@ -128,7 +128,7 @@ def soundcloud_delete(token, track_id):
|
||||||
|
|
||||||
|
|
||||||
@celery.task(name='podcast-download', acks_late=True)
|
@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
|
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 api_key: API key for callback authentication
|
||||||
:param podcast_name: Name of podcast to be added to id3 metadata for smartblock
|
: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 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
|
:return: JSON formatted string of a dictionary of download statuses
|
||||||
and file identifiers (for successful uploads)
|
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
|
# so we treat it like a mp3 if it has a mp3 file extension and hope for the best
|
||||||
if filename.endswith(mp3suffix):
|
if filename.endswith(mp3suffix):
|
||||||
metadata_audiofile = mutagen.mp3.MP3(audiofile.name, ID3=mutagen.easyid3.EasyID3)
|
metadata_audiofile = mutagen.mp3.MP3(audiofile.name, ID3=mutagen.easyid3.EasyID3)
|
||||||
#replace album title as needed
|
#replace track metadata as indicated by album_override setting
|
||||||
metadata_audiofile = podcast_override_album(metadata_audiofile, podcast_name, album_override)
|
# replace album title as needed
|
||||||
|
metadata_audiofile = podcast_override_metadata(metadata_audiofile, podcast_name, album_override, track_title)
|
||||||
metadata_audiofile.save()
|
metadata_audiofile.save()
|
||||||
filetypeinfo = metadata_audiofile.pprint()
|
filetypeinfo = metadata_audiofile.pprint()
|
||||||
logger.info('filetypeinfo is {0}'.format(filetypeinfo.encode('ascii', 'ignore')))
|
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
|
obj['status'] = 0
|
||||||
return json.dumps(obj)
|
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
|
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:
|
if override is True:
|
||||||
logger.debug('overriding album name to {0} in podcast'.format(podcast_name.encode('ascii', 'ignore')))
|
logger.debug('overriding album name to {0} in podcast'.format(podcast_name.encode('ascii', 'ignore')))
|
||||||
m['album'] = podcast_name
|
m['album'] = podcast_name
|
||||||
|
m['title'] = track_title
|
||||||
else:
|
else:
|
||||||
# replace the album id3 tag with the podcast name if the album tag is empty
|
# replace the album id3 tag with the podcast name if the album tag is empty
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue