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

Uploaded Python 3

File details

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

File metadata

  • Download URL: spotipyfree-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 00c64a64f05a1979a682d9896dd0ba7e3d4b14d4a1b50372b9c6c4469660493b
MD5 b293437a6947004bc0a3abb65aab7361
BLAKE2b-256 e43d35cd9dc4a6498f9d0bd6b2261d7afa5f7330d95d65d20c4e3fcd88d92e36

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spotipyfree-1.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4433319ff7836ea07c796d2d975351084e0464dacce0023a3d246bd186caef76
MD5 81f8409629191c35b25ad072f19d9790
BLAKE2b-256 dd3c84c18528dceb235214d9ef0edd14017be8d5ddd61558ad837f09cf8d81cf

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