A Discord bot that identifies which distributor was used to release a track on Spotify.
- Accepts Spotify track links
- Converts Spotify track IDs to UUIDs
- Queries Spotify's metadata API
- Returns the distributor associated with the track (based on hardcoded mappings)
pip install -r requirements.txtCopy .env.example to .env and fill in your credentials:
cp .env.example .envYou'll need:
- DISCORD_BOT_TOKEN: Get this from Discord Developer Portal
- SPOTIFY_SP_DC: Get this from your browser cookies when logged into Spotify Web Player
- Open browser DevTools → Application → Cookies →
open.spotify.com - Copy the value of the
sp_dccookie
- Open browser DevTools → Application → Cookies →
Edit distributors.py and add your UUID → distributor mappings in the DISTRIBUTOR_MAP dictionary.
python bot.pyOr with environment variables:
export DISCORD_BOT_TOKEN=your_token
export SPOTIFY_SP_DC=your_sp_dc
python bot.pyIn Discord, use the command:
!distributor <spotify_link>
Or just:
!distributor
And reply to a message containing a Spotify link.
Examples:
!distributor https://open.spotify.com/track/4iV5W9uYEdYUVa79Axb7Rh!distributor spotify:track:4iV5W9uYEdYUVa79Axb7Rh
- Extracts the base62 track ID from the Spotify URL
- Converts it to a hex GID (UUID) using base62 decoding
- Queries Spotify's internal metadata API with the GID
- Matches the UUID against hardcoded distributor mappings
- Returns the distributor name
- The TOTP implementation may need adjustment based on Spotify's actual requirements
- You'll need to manually populate the distributor mappings by associating UUIDs with distributor names
- The bot requires a valid
sp_dccookie token for authentication