Exemplo n.º 1
0
    def dynamic_data(songs, session_id=""):
        """
        :param songs: a list of dicts ``{'id': '...', 'albumArtUrl': '...'}``
        """
        supported = {
            'id', 'albumArtUrl', 'title', 'artist', 'albumArtist', 'album'
        }
        for s in songs:
            for k in s.keys():
                if k not in supported:
                    raise ValueError(
                        "ChangeSongMetadata only supports the the following keys: "
                        + str(supported) +
                        ". All other keys must be removed. Key encountered:" +
                        k)

        # jsarray is just wonderful
        jsarray = [[session_id, 1]]
        song_arrays = [[
            s['id'],
            s.get('title'),
            s.get('albumArtUrl'),
            s.get('artist'),
            s.get('album'),
            s.get('albumArtist')
        ] + [None] * 33 + [[]] for s in songs]
        jsarray.append([song_arrays])

        return json.dumps(jsarray)
    def dynamic_data(songs, session_id=""):
        """
        :param songs: a list of dicts ``{'id': '...', 'albumArtUrl': '...'}``
        """
        if any([s for s in songs if set(s.keys()) != set(['id', 'albumArtUrl'])]):
            raise ValueError("ChangeSongMetadata only supports the 'id' and 'albumArtUrl' keys."
                             " All other keys must be removed.")

        # jsarray is just wonderful
        jsarray = [[session_id, 1]]
        song_arrays = [[s['id'], None, s['albumArtUrl']] + [None] * 36 + [[]] for s in songs]
        jsarray.append([song_arrays])

        return json.dumps(jsarray)
Exemplo n.º 3
0
    def dynamic_data(songs, session_id=""):
        """
        :param songs: a list of dicts ``{'id': '...', 'albumArtUrl': '...'}``
        """
        if any([s for s in songs if set(s.keys()) != {'id', 'albumArtUrl'}]):
            raise ValueError("ChangeSongMetadata only supports the 'id' and 'albumArtUrl' keys."
                             " All other keys must be removed.")

        # jsarray is just wonderful
        jsarray = [[session_id, 1]]
        song_arrays = [[s['id'], None, s['albumArtUrl']] + [None] * 36 + [[]] for s in songs]
        jsarray.append([song_arrays])

        return json.dumps(jsarray)
Exemplo n.º 4
0
    def dynamic_data(songs, session_id=""):
        """
        :param songs: a list of dicts ``{'id': '...', 'albumArtUrl': '...'}``
        """
        supported = {'id', 'albumArtUrl', 'title', 'artist', 'albumArtist', 'album'}
        for s in songs:
            for k in s.keys():
                if k not in supported:
                    raise ValueError("ChangeSongMetadata only supports the the following keys: "
                                     + str(supported) +
                                     ". All other keys must be removed. Key encountered:" + k)

        # jsarray is just wonderful
        jsarray = [[session_id, 1]]
        song_arrays = [[s['id'],
                        s.get('title'),
                        s.get('albumArtUrl'),
                        s.get('artist'),
                        s.get('album'),
                        s.get('albumArtist')]
                       + [None] * 33 + [[]] for s in songs]
        jsarray.append([song_arrays])

        return json.dumps(jsarray)