I wanted to be able to push my now-listening status (including album art) to my company's Slack.
cp config.default.json config.json
Open the Slack customization page, e.g. subdomain.slack.com/customize
. Open the console (F12) and paste:
window.prompt("Your API token is: ", TS.boot_data.api_token)
Copy the API token from the popup and replace YOUR_SLACK_TOKEN
with your actual token.
Replace my-album-art
with your desired Slack emoji name
This integration has been tested on the following players:
- Google Play Music Desktop Player
- Spotify (Linux client)
- Pithos (Linux Pandora client)
You need to be playing your media before moving on to step 4.
python mpris-track-change-to-slack.py
The script will let you know which media player it found. For example, I see this when I start Google Play Music:
Currently playing: Google Play Music Desktop Player
You can either wait until the current track finishes playing on its own, or if you're feeling impatient, skip to the next track to manually trigger the "track change" functionality. The script will attempt to:
- save your album art as a Slack emoji and
- set your status to the now-playing text including the artist and title and the album-art emoji
Attempting to set status: Now Playing: INXS - Devil Inside
Success
If the script is unable to create the album-art emoji (because of a bad token, no local album art, whatever), it will try to set the status using a standard emoji instead, randomly picking one of the following:
- 💿 (
:cd:
) - 🎧 (
:headphones:
) - 🎵 (
:musical_note:
) - 🎶 (
:notes:
) - 📻 (
:radio:
)
Thanks to Jack Ellenberger (@jackellenberger) for his ":slack_on_fire:" article and his emojme library (particularly emoji-add.js
) for helping me figure out how to push an emoji to Slack's undocumented /api/emoji.add
endpoint.