Description:
A class designed to control the Spotify player API without requiring a Spotify Premium account.
NOTE: Only works at the moment if you dump your own cookies. Find out how to import cookies HERE
Description:
Initializes the Player class and sets up the player to interact with the specified device or active device.
Parameters:
login (Login): The login instance used for authentication.device_id (str, optional): The device ID to connect to for the player. If not provided, it will use the active device.use_active_device (bool): If True, the player will use the active device.
Example:
login_instance = Login(username, password)
player = Player(login_instance)Description:
Transfers the player streamer from one device to another.
Parameters:
from_device_id (str): The device ID to transfer from.to_device_id (str): The device ID to transfer to.
Example:
player.transfer_player("device_1", "device_2")Description:
Sends a generic command to the player.
Parameters:
from_device_id (str): The device ID to send the command from.to_device_id (str): The device ID to send the command to.command (str): The command to send.
Example:
player.run_command("device_1", "device_2", "pause")Description:
Seeks to a specific position in the player.
Parameters:
position_ms (int): The position in milliseconds to seek to.
Example:
player.seek_to(30000)Description:
Restarts the current song.
Example:
player.restart_song()Description:
Pauses the player.
Example:
player.pause()Description:
Resumes the player.
Example:
player.resume()Description:
Skips to the next track.
Example:
player.skip_next()Description:
Skips to the previous track.
Example:
player.skip_prev()Description:
Adds a track to the player's queue.
Parameters:
track (str): The track URI to add to the queue.
Example:
player.add_to_queue("spotify:track:6rqhFgbbKwnb9MLmUQDhG6")Description:
Overrides the player with a new track.
Parameters:
track (str): The track URI to play.playlist (str): The playlist URI to play the track from.
Example:
player.play_track("spotify:track:6rqhFgbbKwnb9MLmUQDhG6", "spotify:playlist:37i9dQZF1DXcBWIGoYBM5M")Description:
Repeats the current track.
Parameters:
value (bool): Whether to repeat the track or disable repeating.
Example:
player.repeat_track(True)Description:
Sets the volume of the player.
Parameters:
volume_percent (float): The volume to set the player to. Must be a percent representation between 0.0 and 1.0.
Example:
player.set_volume(0.5)fade_in_volume(self, volume_percent: float, /, duration_ms: int = 500, *, request_time_ms: int | None = None) -> None
Description:
Slowly increases or decreases the volume of the player.
Parameters:
volume_percent (float): The target volume to set the player to. Must be between 0.0 and 1.0.duration_ms (int): The duration of the fade-in in milliseconds. Defaults to 500ms.request_time_ms (int, optional): If not None, it will account for the request time in theduration_ms.
Example:
player.fade_in_volume(0.7, duration_ms=1000)