Exemplo n.º 1
0
    def _get_music_services_data_xml(soco=None):
        """Fetch the music services data xml from a Sonos device.

        Args:
            soco (SoCo): a SoCo instance to query. If none is specified, a
            random device will be used.

        Returns:
            (str): a string containing the music services data xml

        """
        device = soco or discovery.any_soco()
        log.debug("Fetching music services data from %s", device)
        available_services = device.musicServices.ListAvailableServices()
        descriptor_list_xml = available_services[
            'AvailableServiceDescriptorList']
        log.debug("Services descriptor list: %s", descriptor_list_xml)
        return descriptor_list_xml
Exemplo n.º 2
0
    def _get_account_xml(soco):
        """Fetch the account data from a Sonos device.

        Args:
            soco (SoCo): a SoCo instance to query. If soco is none, a
                random device will be used.

        Returns:
            (str): a byte string containing the account data xml

        """
        # It is likely that the same information is available over UPnP as well
        # via a call to
        # systemProperties.GetStringX([('VariableName','R_SvcAccounts')]))
        # This returns an encrypted string, and, so far, we cannot decrypt it
        device = soco or discovery.any_soco()
        log.debug("Fetching account data from %s", device)
        settings_url = "http://{0}:1400/status/accounts".format(
            device.ip_address)
        result = requests.get(settings_url).content
        log.debug("Account data: %s", result)
        return result
Exemplo n.º 3
0
    def __init__(self, endpoint, timeout, music_service):
        """ Initialise the instance

        Args:
             endpoint (str): The SOAP endpoint. A url.
             timeout (int): Timeout the connection after this number of
                 seconds
             music_service (MusicService): The MusicService object to which
                 this client belongs

        """

        self.endpoint = endpoint
        self.timeout = timeout
        self.music_service = music_service
        self.namespace = 'http://www.sonos.com/Services/1.1'

        self._cached_soap_header = None

        # Spotify uses gzip. Others may do so as well. Unzipping is handled
        # for us by the requests library. We set the user agent to a genuine
        # Sonos value since in some tests Google Play music seems to want
        # this. The firmware release number (after 'Sonos/') is obviously
        # fake, and higher than current values, in case Google only offers
        # certain services to certain firmware releases. ") Although we have
        # access to a real SONOS user agent string (one is returned, eg,
        # in the SERVER header of discovery packets and looks like this:
        # Linux UPnP/1.0 Sonos/29.5-91030 (ZPS3)) it is a bit too much
        # trouble here to access it, when this seems to work

        self.http_headers = {
            'Accept-Encoding': 'gzip, deflate',
            'User-agent': '"Linux UPnP/1.0 Sonos/99 (ZPS3)"'
        }
        self._device = discovery.any_soco()
        self._device_id = self._device.systemProperties.GetString(
            [('VariableName', 'R_TrialZPSerial')])['StringValue']