Skip to main content

Discofy allows control of Spotify playback through Discord API, offering features like play/pause, track skipping, volume control, and device management.

Project description

Discofy

Wanna control Spotify playback API but you don't want to pay for a Spotify Premium? No problem!
Discofy is a Python library that allows you to control Spotify playback for free, without a premium subscription — just by using your Discord account.

Requirements

  • Your Spotify account have to be connected to your Discord account (in Discord settings under "Connections").
  • You must enable "Display Spotify as your status" in Discord.
  • You need your Discord account token (check online resources on how to get it).
  • Discofy will stop working shortly after you close the Discord app.

Features

  • Spotify Integration: Control your Spotify playback through your Discord connection.
  • Playback Control: Pause, resume, skip tracks, or go back to the previous one.
  • Track Management: Play a specific song or add it to the queue.
  • Volume Adjustment: Set the volume between 0 and 100.
  • Shuffle & Repeat Modes: Enable or disable shuffle and repeat functions.
  • Playback Monitoring: Get information about the currently playing track.
  • Device Management: Transfer playback to another linked device.
  • Seek to Position: Jump to a specific time in a track.
  • Add to Queue: Queue tracks for playback.

Installation

To install Discofy, simply use pip: pip install discofy

Available Commands

  • pause_track() - Pauses the currently playing track.
  • resume_track() - Resumes playback if paused.
  • next_track() - Skips to the next track.
  • previous_track() - Goes back to the previous track.
  • play_track(track_uri: str) - Plays a specific track. Example:
    client.play_track("spotify:track:PASTE_TRACK_ID")
  • set_volume(volume: int) - Changes the playback volume (0-100%). Example:
    client.set_volume(10) # Sets volume to 10%
  • get_current_track() - Returns information about the currently playing track.
  • shuffle(state: bool) - Toggles shuffle mode.
  • repeat(state: str) - Changes the repeat mode ('track', 'context', or 'off').
  • is_playing() - Returns True if music is playing, otherwise False.
  • get_playback_state() - Retrieves information about the user's current playback state (track, progress, active device, etc.).
  • transfer_playback(device_id: str, play: bool) - Moves playback to another device.
  • get_available_devices() - Lists available Spotify Connect devices (some may not be supported).
  • seek_to_position(position_ms: int) - Moves playback to a specific position in milliseconds.
  • add_to_playback_queue(track_uri: str) - Adds a track to the queue. Example:
    client.add_to_playback_queue("spotify:track:PASTE_TRACK_ID")

Example Usage

Basic Python script to control Spotify playback with Discofy:

from discofy import Discofy  

# Set your Discord token  
discord_token = "PASTE_YOUR_TOKEN_HERE"  

client = Discofy(discord_token)  

# Set volume to 10%  
client.set_volume(10)  

# Pause playback  
client.pause_track()  

# Print info about the currently playing track  
print(client.get_current_track())  

# Shows if something is being played
if judeify.is_playing():
    print("Something is being played")
else:
    print("Nothing is being played!")

License

Discofy is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
For more details, visit: https://creativecommons.org/licenses/by-sa/4.0/

Change Log

1.2 (02/03/2025)

  • First release

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

discofy-1.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

discofy-1.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file discofy-1.2.tar.gz.

File metadata

  • Download URL: discofy-1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for discofy-1.2.tar.gz
Algorithm Hash digest
SHA256 7a42a6e47528bdae0847e5d928f4e4842f56f341a5326779ff63a8edde9ada8b
MD5 30f0e6ed57c2bad0aa3f25f1798f8d46
BLAKE2b-256 5a708071b5bf1d03666b9343130967121bb5c22a0f82931c6ed2ebfc8089bf79

See more details on using hashes here.

File details

Details for the file discofy-1.2-py3-none-any.whl.

File metadata

  • Download URL: discofy-1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for discofy-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ffb47b139032142c9966a6f47e894307790580e1841fba5a270433cc2786f22
MD5 5412194429f87040f02a3cfbc564cfd3
BLAKE2b-256 064c80d0e57dab49fd14e471b91e1e25e06c31bcd13924532d7c0cb45ca795d9

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