-
Install dependencies:
pip install -r requirements.txt
-
Run the script:
python3.9 spotiAFK.py
It is a simple AFK program that plays Spotify when you are not using your account. To support your favorite artists on the platform.
It uses the Spotify API to check if you are listening to music and if you don't for a while, it starts playing on a device you specify.
-
Make the bot
-
Open a dm with BotFather and click on start
-
Send a message with the text
/newbotand follow the instructions -
Send a message with the text
/mybotsand select the bot we just created- Note that if you want to customize your bot, you can do that also here with
Edit Bot
- Note that if you want to customize your bot, you can do that also here with
-
Select
API Tokenand copy the token and
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
DON'T SHARE THOSE STRINGS WITH ANYONE
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
-
-
Make
telegram.conf-
In the terminal run
sudo python3.9 -m telegram-send -c -g -
Paste your API token you just copied
-
Send the password to your telegram bot click first on
start -
In the terminal run
sudo mv /etc/telegram-send.conf telegram.conf
-
options.py
# Playing
SKIP_SONGS = True
SKIP_DELAY = 35
RANDOM_ORDER_TRACKS = True
# API
CLIENT_ID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
CLIENT_SECRET = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
REDIRECT_URI = "http://localhost:8888/callback/"
# Account
USERNAME = "USERNAME"
PLAYLIST_NAME = "PLAYLIST"
SERVER_NAMES = ["SERVER-1", "SERVER-2", "SERVER-3", "SERVER-4"]
# Checks
CHEAKS_BEFORE_PLAYING = 5
TIME_BETWEEN_CHEAKS = 30
# Errors
RETRY_TIME = 10
# Notifications
NOTIFICATION_ENABLED = True
NOTIFICATION_FILENAME = "telegram.conf"
START_PROGRAM_NOTIFICATION = "Starting program 🏁"
START_PLAYING_NOTIFICATION = "Started playing 🟩"
STOP_PLAYING_NOTIFICATION = "Stopped playing 🟥"
SEND_NOTIFICATION_ON_ERROR = True
# Timelogging
TIMELOG_FILENAME = "time.txt"-
Playing
Function Default Format SKIP_SONGS If the program skips songs or not True True/False SKIP_DELAY Amount of time in seconds that the program waits before skipping a song 35 All numbers above 30 RANDOM_ORDER_TRACKS If the program shuffles the playlist True True/False -
API
-
Get your API tokens
-
Go to the Spotify developer dashboard
-
Log in with your Spotify account
-
Click on
create an app -
Pick an
app nameandapp descriptionof your choice and mark the checkboxes -
After creation, you see your
client Idand you can click onshow client secretto show yourclient secretand copy them
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
DON'T SHARE THOSE STRINGS WITH ANYONE
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ -
Click on
edit settingsand add your redirection URL byredirect uristhan clicksave
-
Function Default Format CLIENT_ID Spotify application client id XXXXX Your client id CLIENT_SECRET Spotify application client secret XXXXX Your client secret REDIRECT_URI Your redirect uri http://localhost:8888/callback/ Your redirect URI you added into the spotify API -
-
Account
Function Default Format USERNAME Your spotify username USERNAME Your spotify username PLAYLIST_NAME The name of the playlist you want to use PLAYLIST Your playlist name SERVER_NAMES The names of devices you want to use ["SERVER-1", "SERVER-2", "SERVER-3", "SERVER-4"] Python list with names of devices What is a "server"?
In this application, a "server" is any device (like your computer, phone, or smart speaker) that can play music from your Spotify account.
You need to tell the script which device to use by editing the
SERVER_NAMESlist inoptions.py. To find the correct name for your device, open the Spotify app, click on the "Connect to a device" icon, and use the name you see there.Hint: A great way to use this is with a Raspberry Pi running
spotifyd. This allows you to have a dedicated, low-power device to act as a "server" without needing speakers connected to it. -
Checks
Function Default Format CHEAKS_BEFORE_PLAYING Amount of checks if your account is free to use before playing 5 All numbers above 0 TIME_BETWEEN_CHEAKS Amount of time in seconds between cheaks if account is free to use 35 All numbers above 0 -
Errors
Function Default Format RETRY_TIME Amount of time in seconds before retrying after an error 10 All numbers above 0 -
Notifications
Function Default Format NOTIFICATION_FILENAME The name of the notification config file telegram.conf Any string preferred with a extension START_PROGRAM_NOTIFICATION Text of notification when program starts Starting program 🏁 Any string START_PLAYING_NOTIFICATION Text of notification when the music starts playing on the server Started playing 🟩 Any string NOTIFICATION_FILENAME Text of notification when the music stops playing on the server Stopped playing 🟥 Any string SEND_NOTIFICATION_ON_ERROR If you want an error notification True True/False -
Timelogging
Function Default Format TIMELOG_FILENAME The name of the timelog file time.txt Any string preferred with a extension
