rahims/SoCo

[Feature Request] Get radio logo

avjui opened this issue · 4 comments

Hi

It would be nice to get the radio logo.
I think it will work when you parsing this directly from tunein

with

http://opml.radiotime.com/Describe.ashx?c=nowplaying&id=${ID}&partnerId=Sonos&serial=${SONOS_SERIAL}
the id you become from the radio request return

<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="R:0/0/0" parentID="R:0/0" restricted="false">
    <dc:title>105.9 | Power 106 (Hip Hop)</dc:title>
    <upnp:class>object.item.audioItem.audioBroadcast</upnp:class>
    <res protocolInfo="x-rincon-mp3radio:*:*:*">x-sonosapi-stream:s34767?sid=254&amp;flags=32</res>
  </item>
</DIDL-Lite>

the id isin this example the s34767

For parsing id and get xml to parse the logo

#!/usr/bin/env python
from soco import SoCo

if __name__ == '__main__':
    sonos = SoCo('10.0.0.20') # Pass in the IP of your Sonos speaker

    mac = sonos.get_speaker_info()['serial_number']
    items = sonos.get_favorite_radio_stations(start=0, max_items=9)

    for favorite in items['favorites']:
        id = favorite['uri'].split('?')[0].split(':')[1]
        xml= "http://opml.radiotime.com/Describe.ashx?c=nowplaying&id=%s&partnerId=Sonos&serial=%s"% (id, mac)

Thanks, @avjui! I going to be pretty busy moving apartments for the next week, but I'll bring your code into the library right after. Thanks again!

phut commented

You are a bit better off using this link - it gives the station info as opposed to the current track from avjul's code

http://opml.radiotime.com/Describe.ashx?id=%s&detail=affiliate,genre,recommendation&partnerId=Sonos&serial=%s

Development of SoCo continues under https://github.com/SoCo If the work is still relavant, please re-open under that project.