Skip to main content

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_playlists Returns 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

  1. Selenium logs into accounts.spotify.com

  2. The web player is opened

  3. The script navigates to the queue page

  4. Track metadata is extracted from the DOM

  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spotipyfree-1.0.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spotipyfree-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file spotipyfree-1.0.0.tar.gz.

File metadata

  • Download URL: spotipyfree-1.0.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for spotipyfree-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4f253f20e618f50a91a3e19738fab1cb923a6fb8ff44b67fef044f74bb1e1d1f
MD5 8d410a03a01d2677ff8ce27ad5407816
BLAKE2b-256 eda0321440afb4755e209cc3a0be74a1f74e042d580d9a4d03a23f0cbd89077a

See more details on using hashes here.

File details

Details for the file spotipyfree-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: spotipyfree-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for spotipyfree-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 585bf3cb516b0564f6d94b94599abeb31711b88568a51a8f9bf8d71aae1560df
MD5 100679a193fa40f095a66b7e81fa7fea
BLAKE2b-256 93a95e5c03b5e02a1e6aeabf0c43c851fe3d89d7f016906b3e9c20ab299ad49a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page