How to use the soco.data_structures.DidlResource function in soco

To help you get started, we’ve selected a few soco examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_create_didl_resource_with_no_params(self):
        with pytest.raises(TypeError):
            res = data_structures.DidlResource()
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_create_didl_resource(self):
        res = data_structures.DidlResource('a%20uri', 'a:protocol:info:xx')
        assert res.uri == 'a%20uri'
        assert res.protocol_info == 'a:protocol:info:xx'
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_object_to_dict_resources(self):
        resources_list = [data_structures.DidlResource('a%20uri',
                                                       'a:protocol:info:xx')]
        didl_object = data_structures.DidlObject(title='a_title',
                                                 parent_id='pid',
                                                 item_id='iid',
                                                 creator='a_creator',
                                                 resources=resources_list)
        the_dict = {
            'title': 'a_title',
            'parent_id': 'pid',
            'item_id': 'iid',
            'creator': 'a_creator',
            'restricted': True,
            'desc': 'RINCON_AssociatedZPUDN',
            'resources': [resource.to_dict() for resource in resources_list]
        }
        assert didl_object.to_dict() == the_dict
github tdamdouni / Pythonista / automation / SoCoSono / unittest / test_new_datastructures.py View on Github external
def test_create_didl_resource_to_from_element(self):
        res = data_structures.DidlResource('a%20uri', 'a:protocol:info:xx',
            bitrate=3)
        elt = res.to_element()
        assert XML.tostring(elt) == (
            b'a%20uri')
        assert data_structures.DidlResource.from_element(elt).__dict__ == \
            res.__dict__
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_object_from_dict_resources(self):
        resources_list = [data_structures.DidlResource('a%20uri',
                                                       'a:protocol:info:xx')]
        didl_object = data_structures.DidlObject(title='a_title',
                                                 parent_id='pid',
                                                 item_id='iid',
                                                 creator='a_creator',
                                                 desc='dummy',
                                                 resources=resources_list)
        the_dict = {
            'title': 'a_title',
            'parent_id': 'pid',
            'item_id': 'iid',
            'creator': 'a_creator',
            'restricted': True,
            'desc': 'dummy',
            'resources': [resource.to_dict() for resource in resources_list]
        }
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_resource_from_dict_remove_nones(self):
        res = data_structures.DidlResource('a%20uri', 'a:protocol:info:xx')
        rez = data_structures.DidlResource.from_dict(
            res.to_dict(remove_nones=True))
        assert res == rez
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_resource_from_dict(self):
        res = data_structures.DidlResource('a%20uri', 'a:protocol:info:xx')
        rez = data_structures.DidlResource.from_dict(res.to_dict())
        assert res == rez
github SoCo / SoCo / soco / core.py View on Github external
title: Name of the playlist

        :rtype: :py:class:`~.soco.data_structures.DidlPlaylistContainer`
        """
        response = self.avTransport.CreateSavedQueue([
            ('InstanceID', 0),
            ('Title', title),
            ('EnqueuedURI', ''),
            ('EnqueuedURIMetaData', ''),
        ])

        item_id = response['AssignedObjectID']
        obj_id = item_id.split(':', 2)[1]
        uri = "file:///jffs/settings/savedqueues.rsq#{0}".format(obj_id)

        res = [DidlResource(uri=uri, protocol_info="x-rincon-playlist:*:*:*")]
        return DidlPlaylistContainer(
            resources=res, title=title, parent_id='SQ:', item_id=item_id)
github SoCo / SoCo / soco / data_structures.py View on Github external
def from_dict(cls, content):
        """Create an instance from a dict.

        An alternative constructor. Equivalent to ``DidlObject(**content)``.

        Args:
            content (dict): a dict containing metadata information. Required.
                Valid keys are the same as the parameters for `DidlObject`.

        """
        # Do we really need this constructor? Could use DidlObject(**content)
        # instead.  -- We do now
        if 'resources' in content:
            content['resources'] = [DidlResource.from_dict(x)
                                    for x in content['resources']]
        return cls(**content)
github SoCo / SoCo / soco / core.py View on Github external
def add_uri_to_queue(self, uri, position=0, as_next=False):
        """Add the URI to the queue.

        For arguments and return value see `add_to_queue`.
        """
        # FIXME: The res.protocol_info should probably represent the mime type
        # etc of the uri. But this seems OK.
        res = [DidlResource(uri=uri, protocol_info="x-rincon-playlist:*:*:*")]
        item = DidlObject(resources=res, title='', parent_id='', item_id='')
        return self.add_to_queue(item, position, as_next)