music.spotify
Platypush documentation
music.spotify
- class platypush.backend.music.spotify.MusicSpotifyBackend(librespot_path: str = 'librespot', device_name: Optional[str] = None, device_type: str = 'speaker', audio_backend: str = 'alsa', audio_device: Optional[str] = None, mixer: str = 'softvol', mixer_name: str = 'PCM', mixer_card: str = 'default', mixer_index: int = 0, volume: int = 100, volume_ctrl: str = 'linear', bitrate: int = 160, autoplay: bool = False, disable_gapless: bool = False, username: Optional[str] = None, password: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, proxy: Optional[str] = None, ap_port: Optional[int] = None, disable_discovery: bool = False, cache_dir: Optional[str] = None, system_cache_dir: Optional[str] = None, disable_audio_cache=False, enable_volume_normalization: bool = False, normalization_method: str = 'dynamic', normalization_pre_gain: Optional[float] = None, normalization_threshold: float = -1.0, normalization_attack: int = 5, normalization_release: int = 100, normalization_knee: float = 1.0, **kwargs)[source]
Bases:
Backend
,SpotifyMixin
This backend uses librespot to turn Platypush into an audio client compatible with Spotify Connect and discoverable by a device running a Spotify client or app. It can be used to stream Spotify through the Platypush host. After the backend has started, you should see a new entry in the Spotify Connect devices list in your app.
Triggers:
platypush.message.event.music.MusicPlayEvent
if the playback state changed to playplatypush.message.event.music.MusicPauseEvent
if the playback state changed to pauseplatypush.message.event.music.MusicStopEvent
if the playback state changed to stopplatypush.message.event.music.NewPlayingTrackEvent
if a new track is being playedplatypush.message.event.music.VolumeChangeEvent
if the volume changes
Requires:
librespot. Consult the README for instructions.
- __init__(librespot_path: str = 'librespot', device_name: Optional[str] = None, device_type: str = 'speaker', audio_backend: str = 'alsa', audio_device: Optional[str] = None, mixer: str = 'softvol', mixer_name: str = 'PCM', mixer_card: str = 'default', mixer_index: int = 0, volume: int = 100, volume_ctrl: str = 'linear', bitrate: int = 160, autoplay: bool = False, disable_gapless: bool = False, username: Optional[str] = None, password: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, proxy: Optional[str] = None, ap_port: Optional[int] = None, disable_discovery: bool = False, cache_dir: Optional[str] = None, system_cache_dir: Optional[str] = None, disable_audio_cache=False, enable_volume_normalization: bool = False, normalization_method: str = 'dynamic', normalization_pre_gain: Optional[float] = None, normalization_threshold: float = -1.0, normalization_attack: int = 5, normalization_release: int = 100, normalization_knee: float = 1.0, **kwargs)[source]
- Parameters:
librespot_path – Librespot path/executable name (default:
librespot
).device_name – Device name (default: same as configured Platypush
device_id
or hostname).device_type – Device type to be shown in the icon. Available types:
unknown
,computer
,tablet
,smartphone
,speaker
,tv
,avr
(Audio/Video Receiver),stb
(Set-Top Box), oraudiodongle
(default:speaker
).audio_backend – Audio backend to be used. Supported values:
alsa
,portaudio
,pulseaudio
,jackaudio
,gstreamer
,rodio
,rodiojack
,sdl
(default:alsa
).audio_device – Output audio device. Type
librespot --device ?
to get a list of the available devices.mixer – Mixer to be used to control the volume. Supported values:
alsa
orsoftvol
(default:softvol
).mixer_name – Mixer name if using the ALSA mixer. Supported values:
PCM
orMaster
(default:PCM
).mixer_card – ALSA mixer output card, as reported by
aplay -l
(default:default
).mixer_index – ALSA card index, as reported by
aplay -l
(default: 0).volume – Initial volume, as an integer between 0 and 100 if
volume_ctrl=linear
or in dB ifvolume_ctrl=logarithmic
.volume_ctrl – Volume control scale. Supported values:
linear
andlogarithmic
(default:linear
).bitrate – Audio bitrate. Choose 320 for maximum quality (default: 160).
autoplay – Play similar tracks when the queue ends (default: False).
disable_gapless – Disable gapless audio (default: False).
username – Spotify user/device username (used if you want to enable Spotify Connect remotely).
password – Spotify user/device password (used if you want to enable Spotify Connect remotely).
client_id – Spotify client ID, required if you want to retrieve track and album info through the Spotify Web API. You can generate one by creating a Spotify app here <https://developer.spotify.com/>.
client_secret – Spotify client secret, required if you want to retrieve track and album info through the Spotify Web API. You can generate one by creating a Spotify app here <https://developer.spotify.com/>.
proxy – Optional HTTP proxy configuration.
ap_port – Spotify AP port to be used (default: default ports, i.e. 80, 443 and 4070).
disable_discovery – Disable discovery mode.
cache_dir – Data files cache directory.
system_cache_dir – System cache directory - it includes audio settings and credentials.
disable_audio_cache – Disable audio caching (default: False).
enable_volume_normalization – Play all the tracks at about the same volume (default: False).
normalization_method – If
enable_volume_normalization=True
, this setting specifies the volume normalization method. Supported values:basic
,dynamic
(default:dynamic
).normalization_pre_gain – Pre-gain applied to volume normalization if
enable_volume_normalization=True
, expressed in dB.normalization_threshold – If
enable_volume_normalization=True
, this setting specifies the normalization threshold (in dBFS) to prevent audio clipping (default: -1.0).normalization_attack – If
enable_volume_normalization=True
, this setting specifies the attack time (in ms) during which the dynamic limiter is reducing the gain (default: 5).normalization_release – If
enable_volume_normalization=True
, this setting specifies the release time (in ms) for the dynamic limiter to restore the gain (default: 100).normalization_knee – Knee steepness of the dynamic limiter (default: 1.0).