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.2.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.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spotipyfree-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 62573c59e80a6c4a035deae361d496fea28cac3ecc893f9bd327983d23ca538c
MD5 5533a71150efb52539a784f6d9b3fa53
BLAKE2b-256 00b674cb4017068a3ad00c2827b0365ae950454b792d59bfd8864ef1371d44e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spotipyfree-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a38322932edbb86f69bf7b44537b3c4d882aba83a1690fd22cf86ed5c2aad25c
MD5 881f9fb955998e2be0359a073e47b16e
BLAKE2b-256 359d13229ca6f858ee0521d396a62e79a8b2ead18d174c27e942d3c90fe2a800

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