Configuration¶
-
class
spotify.
Config
[source]¶ The session config.
Create an instance and assign to its attributes to configure. Then use the config object to create a session:
>>> config = spotify.Config() >>> config.user_agent = 'My awesome Spotify client' >>> # Etc ... >>> session = spotify.Session(config=config)
-
api_version
¶ The API version of the libspotify we’re using.
You should not need to change this. It defaults to the value provided by libspotify through
spotify.get_libspotify_api_version()
.
-
cache_location
¶ A location for libspotify to cache files.
Defaults to
tmp
in the current working directory.Must be a bytestring. Cannot be shared with other Spotify apps. Can only be used by one session at the time. Optimally, you should use a lock file or similar to ensure this.
-
settings_location
¶ A location for libspotify to save settings.
Defaults to
tmp
in the current working directory.Must be a bytestring. Cannot be shared with other Spotify apps. Can only be used by one session at the time. Optimally, you should use a lock file or similar to ensure this.
-
application_key
¶ Your libspotify application key.
Must be a bytestring. Alternatively, you can call
load_application_key_file()
, and pyspotify will correctly read the file intoapplication_key
.
-
load_application_key_file
(filename=b'spotify_appkey.key')[source]¶ Load your libspotify application key file.
If called without arguments, it tries to read
spotify_appkey.key
from the current working directory.This is an alternative to setting
application_key
yourself. The file must be a binary key file, not the C code key file that can be compiled into an application.
-
user_agent
¶ A string with the name of your client.
Defaults to
pyspotify 2.x.y
.
-
compress_playlists
¶ Compress local copy of playlists, reduces disk space usage.
Defaults to
False
.
-
dont_save_metadata_for_playlists
¶ Don’t save metadata for local copies of playlists.
Defaults to
False
.Reduces disk space usage at the expense of needing to request metadata from Spotify backend when loading list.
-
initially_unload_playlists
¶ Avoid loading playlists into RAM on startup.
Defaults to
False
.See
Playlist.in_ram()
for more details.
-
device_id
¶ Device ID for offline synchronization and logging purposes.
Defaults to
None
.The Device ID must be unique to the particular device instance, i.e. no two units must supply the same Device ID. The Device ID must not change between sessions or power cycles. Good examples is the device’s MAC address or unique serial number.
Setting the device ID to an empty string has the same effect as setting it to
None
.
-
proxy
¶ URL to the proxy server that should be used.
Defaults to
None
.The format is protocol://host:port where protocol is http/https/socks4/socks5.
-
proxy_username
¶ Username to authenticate with proxy server.
Defaults to
None
.
-
proxy_password
¶ Password to authenticate with proxy server.
Defaults to
None
.
-
ca_certs_filename
¶ Path to a file containing the root CA certificates that HTTPS servers should be verified with.
Defaults to
None
. Must be a bytestring file path otherwise.This is not used for verifying Spotify’s servers, but may be used for verifying third parties’ HTTPS servers, like the Last.fm servers if you scrobbling the music you listen to through libspotify.
libspotify for macOS use other means for communicating with HTTPS servers and ignores this configuration.
The file must be a concatenation of all certificates in PEM format. Provided with libspotify is a sample PEM file in the
examples/
dir. It is recommended that the application export a similar file from the local certificate store. On Linux systems, the certificate store is often found at/etc/ssl/certs/ca-certificates.crt
or/etc/ssl/certs/ca-bundle.crt
-
tracefile
¶ Path to API trace file.
Defaults to
None
. Must be a bytestring otherwise.
-