Configuration - WilliamNT/tunesynctool GitHub Wiki

How to read the table below: if a value is marked as optional and the default value associated with it isn't None, the default value will be used as a fallback if the environmental variable isn't provided. Also, there's no need to set all the values. Only set the values for the services that you actually want to interact with.

CLI option name Env. var. name Default value Description
--spotify-client-id SPOTIFY_CLIENT_ID None Client ID of the Spotify app you created
--spotify-client-secret SPOTIFY_CLIENT_SECRET None Client secret of the Spotify app you created
--spotify-redirect-uri SPOTIFY_REDIRECT_URI http://localhost:8888/callback Callback URL of the Spotify app you created
--subsonic-base-url SUBSONIC_BASE_URL http://127.0.0.1 Base URL of your Subsonic compatible API
--subsonic-port SUBSONIC_PORT 4533 Port of your Subsonic compatible API
--subsonic-username SUBSONIC_USERNAME None Username to authenticate with your Subsonic compatible service
--subsonic-password SUBSONIC_PASSWORD None Password to authenticate with your Subsonic compatible service
--subsonic-legacy-auth SUBSONIC_LEGACY_AUTH False Whether to enable legacy authentication for the Subsonic server.
--deezer-arl DEEZER_ARL None ARL token to authenticate with your Deezer account
--youtube-request-headers YOUTUBE_REQUEST_HEADERS None Raw request headers from an authenticated request sent by your browser to music.youtube.com

[!TIP] The Supported services page has instructions to obtain the values listed here.

Using the Configuration class

You can import the Configuration class from the tunesynctool package as usual.

from tunesynctool import Configuration

You have the option to programmatically initialize a new Configuration object through its constructor or by loading options from environmental variables.

[!NOTE] It's good to know that Configuration is frozen after initialization, meaning you can't mutate configuration options after the object has been created.

from_env(cls) -> Configuration

The from_env() method, a factory method, eliminates the need to initialize a Configuration object before its usage. As its name suggests, it constructs a configuration object by retrieving values set within the environment.

[!TIP] Tunesynctool utilizes the python-dotenv package under the hood for automatically loading environmental variables into its configuration. For further details on how this package locates and retrieves environmental values, please refer to its documentation at: https://saurabh-kumar.com/python-dotenv/.

Validation

The validation of configuration values is not performed by the Configuration class, but rather delegated to the specific modules that utilize the configuration values pertinent to their functions. Consequently, in the context of streaming service drivers, each service driver is responsible for validating the configuration relevant to it during the initialization phase.