Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Latest commit

 

History

History
117 lines (68 loc) · 2.5 KB

internal.rst

File metadata and controls

117 lines (68 loc) · 2.5 KB

Internal API

Warning

This page documents pyspotify's internal APIs. Its intended audience is developers working on pyspotify itself. You should not use anything you find on this page in your own applications.

libspotify CFFI interface

The CFFI wrapper for the full libspotify API is available as spotify.ffi and spotify.lib.

spotify.ffi

cffi.FFI instance which knows about libspotify types.

>>> import spotify
>>> spotify.ffi.new('sp_audioformat *')
<cdata 'struct sp_audioformat *' owning 12 bytes>

spotify.lib

Dynamic wrapper around the full libspotify C API.

>>> import spotify
>>> msg = spotify.lib.sp_error_message(spotify.lib.SP_ERROR_OK)
>>> msg
<cdata 'char *' 0x7f29fd922cb5>
>>> spotify.ffi.string(msg)
'No error'

spotify.lib will always reflect the contents of the spotify/api.processed.h file in the pyspotify distribution. To update the API:

  1. Update the file spotify/api.h with the latest header file from libspotify.
  2. Run the Invoke task preprocess_header defined in tasks.py by running:

    invoke preprocess_header

    The task will update the spotify/api.processed.h file.

  3. Commit both header files so that they are distributed with pyspotify.

Thread safety utils

spotify.serialized

Event emitter utils

spotify.utils.EventEmitter

Enumeration utils

spotify.utils.IntEnum

spotify.utils.make_enum

Object loading utils

spotify.utils.load

Sequence utils

spotify.utils.Sequence

String conversion utils

spotify.utils.get_with_fixed_buffer

spotify.utils.get_with_growing_buffer

spotify.utils.to_bytes

spotify.utils.to_bytes_or_none

spotify.utils.to_unicode

spotify.utils.to_unicode_or_none

spotify.utils.to_char

spotify.utils.to_char_or_null

Country code utils

spotify.utils.to_country

spotify.utils.to_country_code