soco.ms_data_structures module
This module contains all the data structures for music service plugins.
- soco.ms_data_structures.get_ms_item(xml, service, parent_id)[source]
Return the music service item that corresponds to xml.
The class is identified by getting the type from the ‘itemType’ tag
- soco.ms_data_structures.tags_with_text(xml, tags=None)[source]
Return a list of tags that contain text retrieved recursively from an XML tree.
- class soco.ms_data_structures.MusicServiceItem(**kwargs)[source]
Class that represents a music service item.
- classmethod from_xml(xml, service, parent_id)[source]
Return a Music Service item generated from xml.
- Parameters
xml (
xml.etree.ElementTree.Element
) – Object XML. All items containing text are added to the content of the item. The class variablevalid_fields
of each of the classes list the valid fields (after translating the camel case to underscore notation). Required fields are listed in the class variable by that name (where ‘id’ has been renamed to ‘item_id’).service (Instance of sub-class of
soco.plugins.SoCoPlugin
) – The music service (plugin) instance that retrieved the element. This service must containid_to_extended_id
andform_uri
methods anddescription
andservice_id
attributes.parent_id (str) – The parent ID of the item, will either be the extended ID of another MusicServiceItem or of a search
For a track the XML can e.g. be on the following form:
<mediaMetadata xmlns="http://www.sonos.com/Services/1.1"> <id>trackid_141359</id> <itemType>track</itemType> <mimeType>audio/aac</mimeType> <title>Teacher</title> <trackMetadata> <artistId>artistid_10597</artistId> <artist>Jethro Tull</artist> <composerId>artistid_10597</composerId> <composer>Jethro Tull</composer> <albumId>albumid_141358</albumId> <album>MU - The Best Of Jethro Tull</album> <albumArtistId>artistid_10597</albumArtistId> <albumArtist>Jethro Tull</albumArtist> <duration>229</duration> <albumArtURI>http://varnish01.music.aspiro.com/sca/ imscale?h=90&w=90&img=/content/music10/prod/wmg/ 1383757201/094639008452_20131105025504431/resources/094639008452. jpg</albumArtURI> <canPlay>true</canPlay> <canSkip>true</canSkip> <canAddToFavorites>true</canAddToFavorites> </trackMetadata> </mediaMetadata>
- classmethod from_dict(dict_in)[source]
Initialize the class from a dict.
- Parameters
dict_in (dict) – The dictionary that contains the item content. Required fields are listed class variable by that name
- property to_dict
Return a copy of the content dict.
- property didl_metadata
Return the DIDL metadata for a Music Service Track.
The metadata is on the form:
<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="...self.extended_id..." parentID="...self.parent_id..." restricted="true"> <dc:title>...self.title...</dc:title> <upnp:class>...self.item_class...</upnp:class> <desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/"> self.content['description'] </desc> </item> </DIDL-Lite>
- property item_id
Return the item id.
- property extended_id
Return the extended id.
- property title
Return the title.
- property service_id
Return the service ID.
- property can_play
Return a boolean for whether the item can be played.
- property parent_id
Return the extended parent_id, if set, otherwise return None.
- property album_art_uri
Return the album art URI if set, otherwise return None.
- class soco.ms_data_structures.MSTrack(title, item_id, extended_id, uri, description, service_id, **kwargs)[source]
Class that represents a music service track.
Initialize MSTrack item.
- property album
Return the album title if set, otherwise return None.
- property artist
Return the artist if set, otherwise return None.
- property duration
Return the duration if set, otherwise return None.
- property uri
Return the URI.
- class soco.ms_data_structures.MSAlbum(title, item_id, extended_id, uri, description, service_id, **kwargs)[source]
Class that represents a Music Service Album.
- property artist
Return the artist if set, otherwise return None.
- property uri
Return the URI.
- class soco.ms_data_structures.MSAlbumList(title, item_id, extended_id, uri, description, service_id, **kwargs)[source]
Class that represents a Music Service Album List.
- property uri
Return the URI.
- class soco.ms_data_structures.MSPlaylist(title, item_id, extended_id, uri, description, service_id, **kwargs)[source]
Class that represents a Music Service Play List.
- property uri
Return the URI.
- class soco.ms_data_structures.MSArtistTracklist(title, item_id, extended_id, uri, description, service_id, **kwargs)[source]
Class that represents a Music Service Artist Track List.
- property uri
Return the URI.
- class soco.ms_data_structures.MSArtist(title, item_id, extended_id, service_id, **kwargs)[source]
Class that represents a Music Service Artist.