Change your slack status to your currently played track on Spotify, regardless of the device!
You will need Python >= 3.7 installed on your computer.
I recommend a virtual environment setup, to isolate this app from any other Python app and not have conflicting packages installed.
After installing Python, go to your terminal:
pip install virtualenv
cd <to your chosen folder location>
git clone https://github.com/JohnAntonios/slackthespot.git
cd slackthespot
virtualenv venv
# For Windows:
.\venv\Scripts\activate
# For Mac OS X / Linux / UNIX:
source venv/bin/activate
pip install -r requirements.txt
You will need to create a .env
file in the root directory of the git folder.
In the .env file, 3 keys are required that you will need to obtain yourself:
This sample file has been provided for you to follow along with.
SLACK_OAUTH_ACCESS_TOKEN
You will need to generate this token in Slack API, simply create an App and link it to your desired workspace, then install the app, this will generate an OAUTH key for you to copy and paste.
SPOTIFY_CLIENT_IDSPOTIFY_CLIENT_SECRET
You will need to generate these two keys in Spotify for Developers.
- Create an App
- Fill in the details and press next.
- Press Non-Commercial
- Confirm to the agreements.
This will now redirect you to the dashboard of your newly created app.
Press SHOW CLIENT SECRET and paste both the Client ID and Client Secret into the .env file.
- Press Edit Settings
- In the Redirect URIs, add:
http:https://localhost/oauth_code
After finally getting the above shenanigans sorted, you are ready to start the app!
python app.py
For the first run, a browser will open requiring you to sign in with the Spotify account you would like to grab the currently playing track from.
After signing in, you will be redirected to http:/localhost/oauth_code?=...
copy the entire URL and paste it in the terminal window.
This will save that user, so that you do not need to authenticate the user again. If you wish to sign in into a different account, simply remove the SPOTIFY_CURRENT_USER_TOKEN key-value from your .env
file.
The app will automatically update your slack status every minute, as there is no event listener / webhook integrated in Spotify's API with Python + Tekore; so polling was implemented.
The app tracks the device that the user is logged into, so it can even update it from your Phone's Spotify!