added track title override for podcasts
This commit is contained in:
parent
7c1bea379c
commit
e2e8591b4d
3 changed files with 11 additions and 7 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue