From d1744f8131d4f6c788fc8c310c083b6befce4fe8 Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Tue, 18 May 2021 10:21:08 +0200 Subject: [PATCH] Ignore unofficial DIDL subclasses denoted by '.#' (#830) Fixes #801. --- soco/data_structures.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/soco/data_structures.py b/soco/data_structures.py index b60e40aa4..efd4a9656 100755 --- a/soco/data_structures.py +++ b/soco/data_structures.py @@ -73,9 +73,11 @@ def to_didl_string(*args): def didl_class_to_soco_class(didl_class): """Translate a DIDL-Lite class to the corresponding SoCo data structures class""" - # Certain music services has been observed to sub-class via a .# syntax - # instead of just . we simply replace it with the official syntax - didl_class = didl_class.replace(".#", ".") + # Certain music services have been observed to sub-class via a .# or # syntax. + # We simply remove these subclasses. + for separator in (".#", "#"): + if separator in didl_class: + didl_class = didl_class[: didl_class.find(separator)] try: cls = _DIDL_CLASS_TO_CLASS[didl_class] @@ -558,8 +560,9 @@ def from_element(cls, element): # pylint: disable=R0914 # In case this class has an # specified unofficial # subclass, ignore it by stripping it from item_class - if ".#" in item_class: - item_class = item_class[: item_class.find(".#")] + for separator in (".#", "#"): + if separator in item_class: + item_class = item_class[: item_class.find(separator)] if item_class != cls.item_class: raise DIDLMetadataError(