From 2e9fc432b14899b9463260a26eeca9b890d2a954 Mon Sep 17 00:00:00 2001 From: Lucas Bickel Date: Sat, 4 Mar 2017 13:24:26 +0100 Subject: [PATCH] Only override album it is empty --- python_apps/airtime-celery/airtime-celery/tasks.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python_apps/airtime-celery/airtime-celery/tasks.py b/python_apps/airtime-celery/airtime-celery/tasks.py index 3e4c1f3e9..2a8474c7b 100644 --- a/python_apps/airtime-celery/airtime-celery/tasks.py +++ b/python_apps/airtime-celery/airtime-celery/tasks.py @@ -152,12 +152,13 @@ def podcast_download(id, url, callback_url, api_key, podcast_name): filename = get_filename(r) with tempfile.NamedTemporaryFile(mode ='wb+', delete=False) as audiofile: shutil.copyfileobj(r.raw, audiofile) - #m = mutagen.File(audiofile.name, easy=True) # currently hardcoded for mp3s may want to add support for oggs etc m = MP3(audiofile.name, ID3=EasyID3) - #m = EasyID3(audiofile.name) - m['album'] = [podcast_name] - m.save() + try: + m['album'] + except KeyError: + m['album'] = [podcast_name] + m.save() filetypeinfo = m.pprint() logger.info('filetypeinfo is {0}'.format(filetypeinfo)) re = requests.post(callback_url, files={'file': (filename, open(audiofile.name, 'rb'))}, auth=requests.auth.HTTPBasicAuth(api_key, ''))