From 546adf13af4f0e294d0ae731530ee05df6af0f64 Mon Sep 17 00:00:00 2001 From: Massimo Mund Date: Fri, 19 May 2017 08:21:09 +0200 Subject: [PATCH] An Emtec N200 (Issue #310) provides "audio/mpegurl" as first mime type accepted by the Mp3Codec class. This leads to the situation that for later play instructions also that mime type is being used. The device certainly expects a text file containing urls and not a byte stream, resulting in an error. - Since the streaming server does not know the concept of mpegurls, simply blacklist them. --- pulseaudio_dlna/codecs.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pulseaudio_dlna/codecs.py b/pulseaudio_dlna/codecs.py index cb671cb5..cdc4e693 100644 --- a/pulseaudio_dlna/codecs.py +++ b/pulseaudio_dlna/codecs.py @@ -94,6 +94,7 @@ class BaseCodec(object): IDENTIFIER = None BACKEND = 'generic' PRIORITY = None + BLACKLISTED_MIME_TYPES = [] def __init__(self): self.mime_type = None @@ -133,8 +134,11 @@ def encoder_type(self): @classmethod def accepts(cls, mime_type): + lower_mime_type = mime_type.lower() + if lower_mime_type in cls.BLACKLISTED_MIME_TYPES: + return False for accepted_mime_type in cls.SUPPORTED_MIME_TYPES: - if mime_type.lower().startswith(accepted_mime_type.lower()): + if lower_mime_type.startswith(accepted_mime_type.lower()): return True return False @@ -195,6 +199,7 @@ def __gt__(self, other): class Mp3Codec(BitRateMixin, BaseCodec): SUPPORTED_MIME_TYPES = ['audio/mpeg', 'audio/mp3'] + BLACKLISTED_MIME_TYPES = ['audio/mpegurl'] IDENTIFIER = 'mp3' ENCODERS = { 'generic': pulseaudio_dlna.encoders.LameMp3Encoder,