Beispiel #1
0
    def __init__(
        self,
        callbacks,
        cache_location="",
        settings_location="",
        app_key=None,
        user_agent=None,
        compress_playlists=False,
        dont_save_metadata_for_playlists=False,
        initially_unload_playlists=False,
        device_id=None,
        proxy=None,
        proxy_username=None,
        proxy_password=None,
        ca_certs_filename=None,
        tracefile=None,
    ):
        # Low level interface
        self.__session_interface = _session.SessionInterface()

        # Callback managers
        self._user_callbacks = spotify.CallbackQueueManager()
        self._metadata_callbacks = spotify.CallbackQueueManager()

        # prepare callbacks
        self.__callback_manager = spotify.CallbackManager()
        self.__callbacks = ProxySessionCallbacks(self, callbacks, self.__callback_manager)

        # app key conversion
        appkey_c = (ctypes.c_byte * len(app_key))(*app_key)

        args = [
            self.api_version,
            cache_location,
            settings_location,
            appkey_c,
            ctypes.sizeof(appkey_c),
            user_agent,
            ctypes.pointer(self.__callbacks.get_callback_struct()),
            ctypes.c_void_p(),
            compress_playlists,
            dont_save_metadata_for_playlists,
            initially_unload_playlists,
            device_id,
            proxy,
            proxy_username,
            proxy_password,
            tracefile,
        ]

        # Linux builds have an extra member just before tracefile
        if is_linux():
            args.insert(-1, ca_certs_filename)

        # initialize app config
        config = _session.config(*args)

        self.__session_struct = ctypes.c_void_p()
        err = self.__session_interface.create(ctypes.byref(config), ctypes.byref(self.__session_struct))
        spotify.handle_sp_error(err)
Beispiel #2
0
    def __init__(self,
                 callbacks,
                 cache_location="",
                 settings_location="",
                 app_key=None,
                 user_agent=None,
                 compress_playlists=False,
                 dont_save_metadata_for_playlists=False,
                 initially_unload_playlists=False,
                 device_id=None,
                 proxy=None,
                 proxy_username=None,
                 proxy_password=None,
                 ca_certs_filename=None,
                 tracefile=None):
        #Low level interface
        self.__session_interface = _session.SessionInterface()

        #Callback managers
        self._user_callbacks = spotify.CallbackQueueManager()
        self._metadata_callbacks = spotify.CallbackQueueManager()

        #prepare callbacks
        self.__callback_manager = spotify.CallbackManager()
        self.__callbacks = ProxySessionCallbacks(self, callbacks,
                                                 self.__callback_manager)

        #app key conversion
        appkey_c = (ctypes.c_byte * len(app_key))(*app_key)

        args = [
            self.api_version,
            cache_location,
            settings_location,
            appkey_c,
            ctypes.sizeof(appkey_c),
            user_agent,
            ctypes.pointer(self.__callbacks.get_callback_struct()),
            ctypes.c_void_p(),
            compress_playlists,
            dont_save_metadata_for_playlists,
            initially_unload_playlists,
            device_id,
            proxy,
            proxy_username,
            proxy_password,
            tracefile,
        ]

        #Linux builds have an extra member just before tracefile
        if is_linux():
            args.insert(-1, ca_certs_filename)

        #initialize app config
        config = _session.config(*args)

        self.__session_struct = ctypes.c_void_p()
        err = self.__session_interface.create(
            ctypes.byref(config), ctypes.byref(self.__session_struct))
        spotify.handle_sp_error(err)
Beispiel #3
0
    ("application_key_size", ctypes.c_uint),
    ("user_agent", ctypes.c_char_p),
    ("callbacks", ctypes.POINTER(callbacks)),
    ("userdata", ctypes.c_void_p),
    ("compress_playlists", bool_type),
    ("dont_save_metadata_for_playlists", bool_type),
    ("initially_unload_playlists", bool_type),
    ("device_id", ctypes.c_char_p),
    ("proxy", ctypes.c_char_p),
    ("proxy_username", ctypes.c_char_p),
    ("proxy_password", ctypes.c_char_p),
    ("tracefile", ctypes.c_char_p)
]

#Linux builds have an extra member just before tracefile
if is_linux():
    tmp_field_list.insert(-1, ("ca_certs_filename", ctypes.c_char_p))
    
config._fields_ = tmp_field_list
tmp_field_list = None


offline_sync_status._fields_ = [
    ("queued_tracks", ctypes.c_int),
    ("queued_bytes", ctypes.c_uint64),
    ("done_tracks", ctypes.c_int),
    ("done_bytes", ctypes.c_uint64),
    ("copied_tracks", ctypes.c_int),
    ("copied_bytes", ctypes.c_uint64),
    ("willnotcopy_tracks", ctypes.c_int),
    ("error_tracks", ctypes.c_int),