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.3.tar.gz (6.6 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.3-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

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

Hashes for spotipyfree-1.0.3.tar.gz
Algorithm Hash digest
SHA256 f23fa75524d5df970ddee0b3b3420178acb8a3d0fe795bfa6145d33c5999e686
MD5 a6f4bf5f7b2be3f52bd5074aea539a6a
BLAKE2b-256 2638b01f9b09bba8beec1c676af423cc9c4c7721ff35de5c1aa00f0f7e97c39f

See more details on using hashes here.

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

Hashes for spotipyfree-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a3dcaf17f631fcafac57dc755d0e102cbc2e02c6eed50c2b5cd24b878805b105
MD5 6d16d5056b59fefe3259085720bf7438
BLAKE2b-256 4d02756ebce33b7a86f370a7ec9a443644047003e02edbe413370a3103697901

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