A Spotipy-compatible wrapper using SpotAPI
Project description
Selenium-Spotify
A lightweight drop-in replacement for Spotipy that uses Selenium to control and read data from the Spotify Web Player.
This project mimics parts of the Spotify Web API without requiring developer credentials or the official API. Instead, it logs into the Spotify web player and scrapes playback information.
Currently the library focuses on retrieving the current playback state in a format compatible with the Spotify API.
Features
-
Drop-in style response compatible with
spotipy -
Cookie saving for faster loading times
-
No Spotify developer account required
-
Works directly with the Spotify Web Player
-
Simple login using username and password
-
Returns playback data structured like the official Spotify API
Current Status
⚠️ This project is experimental.
Currently implemented:
-
current_playback()
Returns playback information similar to the Spotify Web API. -
current_user_playlistsReturns information about playlists the user has saved. Limitations: -
Only the currently playing track and current_user_playlists is supported
-
Some page loads rely on DOM scraping and may break if Spotify updates their UI
-
Occasionally Spotify CAPTCHA may appear during login
Installation
Bash
pip install selenium
You must also install ChromeDriver compatible with your Chrome version.
Usage
Python
Run
from selenium_spotify import Spotify
sp = Spotify("username", "password")
playback = sp.current_playback()
print(playback["item"]["name"])
Example response structure (compatible with Spotipy):
Python
Run
playback["item"]["name"]
playback["item"]["artists"][0]["name"]
playback["item"]["album"]["name"]
Secrets File Example
The included example expects a secrets.json file:
JSON
{
"spotify": {
"username": "your_username",
"password": "your_password"
}
}
How It Works
-
Selenium logs into
accounts.spotify.com -
The web player is opened
-
The script navigates to the queue page
-
Track metadata is extracted from the DOM
-
A response object is generated matching the Spotify Web API format
Known Issues
-
CAPTCHA sometimes appears during login
-
Page structure changes from Spotify can break selectors
-
Selenium adds noticeable overhead compared to API calls
-
Requires a running Chrome browser
-
Code is ugly, I need to fix that...
-
Stealth mode not working
Planned Improvements
-
Faster page scraping
-
More API compatibility
-
devices -
playlists -
pause / play -
next / previous
-
-
Headless mode improvements
Warning
This project uses browser automation and unofficial scraping of the Spotify Web Player.
It is not affiliated with Spotify and may break if Spotify changes their website.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spotipyfree-1.0.3.tar.gz.
File metadata
- Download URL: spotipyfree-1.0.3.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f23fa75524d5df970ddee0b3b3420178acb8a3d0fe795bfa6145d33c5999e686
|
|
| MD5 |
a6f4bf5f7b2be3f52bd5074aea539a6a
|
|
| BLAKE2b-256 |
2638b01f9b09bba8beec1c676af423cc9c4c7721ff35de5c1aa00f0f7e97c39f
|
File details
Details for the file spotipyfree-1.0.3-py3-none-any.whl.
File metadata
- Download URL: spotipyfree-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3dcaf17f631fcafac57dc755d0e102cbc2e02c6eed50c2b5cd24b878805b105
|
|
| MD5 |
6d16d5056b59fefe3259085720bf7438
|
|
| BLAKE2b-256 |
4d02756ebce33b7a86f370a7ec9a443644047003e02edbe413370a3103697901
|