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

Improve parsing r:StreamContent #32

Merged
merged 1 commit into from Jan 15, 2020

Conversation

cheanrod
Copy link
Contributor

This fix improves the handling of field r:StreamContent when streaming e.g. radio stations. In case of my favorite station there isn't always a parseable artist/title combination available. Instead, only the name of the radio station is included (see below).

{ 'DIDL-Lite': { '_xmlns:dc': 'http://purl.org/dc/elements/1.1/', '_xmlns:upnp': 'urn:schemas-upnp-org:metadata-1-0/upnp/', '_xmlns:r': 'urn:schemas-rinconnetworks-com:metadata-1-0/', _xmlns: 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/', item: { _id: '-1', _parentID: '-1', _restricted: 'true', res: [Object], 'r:streamContent': 'Bremen Vier', 'r:radioShowMd': 'HeuckZeug,p270647', 'upnp:albumArtURI': '/getaa?s=1&u=x-sonosapi-stream%3as25565%3fsid%3d254%26flags%3d8224%26sn%3d0', 'dc:title': 'x-sonosapi-stream:s25565?sid=254&flags=8224&sn=0', 'upnp:class': 'object.item' } } }

This is currently parsed as follows:

{
  "AlbumArtUri": "http://192.168.178.41:1400/getaa?s=1&u=x-sonosapi-stream:s25565%3fsid%3d254%26flags%3d8224%26sn%3d0",
  "Title": "x-sonosapi-stream:s25565?sid=254&flags=8224&sn=0",
  "UpnpClass": "object.item",
  "ItemId": "-1",
  "ParentId": "-1",
  "TrackUri": "x-sonosapi-stream:s25565?sid=254&flags=8224&sn=0",
  "ProtocolInfo": "sonos.com-http:*:*:*"
}

This is not nice for displaying it in my smarthome software.

The fix adds the stream content to the artist even if the content cannot be split. Additionally, 'r:radioShowMd' is parsed and added to the title. The result is this:

{
  "Artist": "Bremen Vier",
  "AlbumArtUri": "http://192.168.178.41:1400/getaa?s=1&u=x-sonosapi-stream:s25565%3fsid%3d254%26flags%3d8224%26sn%3d0",
  "Title": "HeuckZeug",
  "UpnpClass": "object.item",
  "ItemId": "-1",
  "ParentId": "-1",
  "TrackUri": "x-sonosapi-stream:s25565?sid=254&flags=8224&sn=0",
  "ProtocolInfo": "sonos.com-http:*:*:*"
}

@cheanrod cheanrod marked this pull request as ready for review January 15, 2020 20:46
@svrooij svrooij merged commit c5498f6 into svrooij:master Jan 15, 2020
@svrooij
Copy link
Owner

svrooij commented Jan 15, 2020

Thanks Sven for your second contribution!

@svrooij
Copy link
Owner

svrooij commented Jan 15, 2020

🎉 This PR is included in version 1.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@cheanrod
Copy link
Contributor Author

Thanks for fast merge!

@cheanrod cheanrod deleted the streamcontent-parsing branch January 15, 2020 21:39
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 this pull request may close these issues.

None yet

2 participants