From 5e904652671d7a79560c3b376501627a53ce4d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Tue, 19 Nov 2019 05:37:03 +0100 Subject: [PATCH] Improve guessing if http fetch fails. If the server doesn't support getting the http head for the feed a 501 may be generated the guess_mime function will in turn fail if the url ends with "?arg=x" or similar. This does an extra parsing step trying to remove such arguments. --- mycroft/audio/services/simple/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mycroft/audio/services/simple/__init__.py b/mycroft/audio/services/simple/__init__.py index e29e9672bb..4aa2f0f2e6 100644 --- a/mycroft/audio/services/simple/__init__.py +++ b/mycroft/audio/services/simple/__init__.py @@ -20,6 +20,7 @@ from mycroft.messagebus.message import Message from mycroft.util.log import LOG from mycroft.util import play_mp3, play_ogg, play_wav import mimetypes +import re from requests import Session @@ -31,6 +32,9 @@ def find_mime(path): mime = response.headers['content-type'] if not mime: mime = mimetypes.guess_type(path)[0] + # Remove any http address arguments + if not mime: + mime = mimetypes.guess_type(re.sub(r'\?.*$', '', path))[0] if mime: return mime.split('/')