From 098df77378c9636de8e494adee0930c523722d8e Mon Sep 17 00:00:00 2001 From: jerryyip <563355085@qq.com> Date: Mon, 21 May 2018 09:32:57 +0800 Subject: [PATCH] check content_type for mp3 stream --- avs/alexa.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/avs/alexa.py b/avs/alexa.py index 6928ac0..13ce30e 100755 --- a/avs/alexa.py +++ b/avs/alexa.py @@ -320,7 +320,7 @@ def iter_lines(response, delimiter=None): logger.debug(json_payload) if 'directive' in json_payload: directives.append(json_payload['directive']) - else: + elif content_type == "application/octet-stream": logger.info("Finished downloading {} which is {}".format( content_type, content_id)) payload.seek(0) @@ -331,9 +331,9 @@ def iter_lines(response, delimiter=None): filename = hashlib.md5(filename).hexdigest() with open(os.path.join(tempfile.gettempdir(), '{}.mp3'.format(filename)), 'wb') as f: f.write(payload.read()) - logger.info('write audio to {}.mp3'.format(content_id)) - + else: + logger.info("Finished downloading {} which is {} abandon it".format(content_type, content_id)) continue elif on_boundary: # logger.debug("Now in header")