Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect UPnP class for unofficial subclass #801

Closed
amelchio opened this issue Jan 27, 2021 · 0 comments · Fixed by #830
Closed

Incorrect UPnP class for unofficial subclass #801

amelchio opened this issue Jan 27, 2021 · 0 comments · Fixed by #830
Assignees

Comments

@amelchio
Copy link
Contributor

I think that I found a regression with #713. When I have a favorite like this:

<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">
  <item id="10092020urn%3adr%3amu%3achannel%3a4f3b8911860d9a33ccfdaf41" parentID="10fe2064live%3adistrict%3ap4" restricted="true">
    <dc:title>DR P4 Fyn</dc:title>
    <upnp:class>object.item.audioItem.audioBroadcast.#channel</upnp:class>
    <desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON74247_</desc>
  </item>
</DIDL-Lite>

and I try to use it like this:

python -c 'import soco; print(soco.SoCo("10.0.2.14").music_library.get_sonos_favorites()[9].reference.resources)'

I get this error:

soco.exceptions.DIDLMetadataError: UPnP class is incorrect. Expected 'object.item.audioItem.audioBroadcast.channel', got 'object.item.audioItem.audioBroadcast'

I have found this to be due to different handling of .#:

# 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(".#", ".")

# 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(".#")]

I was able to fix my test case by making either of those work like the other. However, I am not sure what exactly is happening or what the right path forward would be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants