COS is a platform for automatically generate and play a Spotify playlist based on people (devices) present on a private LAN (e.g. an office LAN). Overall, it works the following way:
- Each slack user have the possibility to associate a Spotify playlist and a number of devices mac addresses with its user
- The platform will then keep track of which mac addresses are online on the private LAN it's running on, an get a list of all playlists associated with the corresponding users
- Given the list of playlists generated, a new playlist is constructed as a weighted union of these playlists
- The playlist is shuffled and played through Mopidy
- When a device is entering or leaving the network, or someone online on the network changes his/her associated playlist, the collaborative playlist is regenerated, shuffled and played
- Playback (play, pause, skip song and play What is love + Het som en Hotshot) is controlled through Slack commands, as well as list current playlist etc
Technically, COS consists of two daemons: slackbot
and office-playlist-daemon
COS requires some additional services to fully function, namely:
- Spotify login credentials plus a Spotify app setup
- Mopidy server
- Slack account and one or more services
- Hubot for slack for controlling playback, playlist contribution etc
- Redis for storage and intra-service communication
Don't have Spotify yet? Shame on you, go get yourself an account! Then register a Spotify app
Mopidy is the server responsible for the actual audio playback of the generated Spotify playlist.
- Websocket API needs to be up and running
- Mopidy-Spotify extension needs to be enabled and configured with Spotify login credentials
- Mopidy-Webhooks extension needs to be enabled
See Mopidy configuration documentation for help setting this up.
Go get yourself and setup a Slack account if you haven't already! And setup a Hubot app.
A Redis server needs to be setup and running. Go fix it!
All settings for the playlist manager daemon is controlled through environment variables. These can be set in an .env-file (daemon/.env
). See daemon/.env.example
.
Required settings are:
REDIS_URL
- connection url to the Redis server to be usedSPOTIFY_CLIENTID
- client id for your spotify app - provided for you when configuring your Spotify appSPOTIFY_CLIENTSECRET
- client secret for your spotify app - provided for you when configuring your Spotify appSPOTIFY_PLAYLIST
- Id of the Spotify playlist to use as collaborative playlist. Needs to be accessible and writeable by the Spotify user Mopidy is running onSPOTIFY_USER
- User name of the spotify account owning the collaborative playlistPING_EXECUTABLE
- Device discovery is done by using ping/ICMP to the broadcast IP of the private LAN. This is the ping executable to be used (platform dependent). Examples:/sbin/ping
,ping -b
etcMOPIDY_WS_URL
- Websocket url to the Mopidy JSON-RPC API
All settings for hubot is controlled through environment variables. These can be set in an .env-file (slackbot/.env
). See slackbot/.env.example
.
Required settings are:
REDIS_URL
- connection url to the Redis server to be usedHUBOT_SLACK_TOKEN
- provided to youe by the Slack Hubot integration.MOPIDY_WS_URL
- Websocket url to the Mopidy JSON-RPC APIPLAYBACK_NOTIFY_CHANNEL
- Name of the channel Hubot should post updates about songs being played to
Optional settings are:
PLAYLIST_EXPIRY_DAYS
- Number of days before a users playlist pick expires
Some commands must be issued in a private conversation with Hubot, others must be issued in a "public" channel.
These commands can only be issued in a private conversation with Slackbot.
update spotify token
- start oauth2 flow to get new spotify access and refresh tokens (for playlist management)set spotify auth code <auth-code>
- complete spotify oauth2 flow by supplying authentication codehookup mac <mac-address>
- associate mac address with your userforget mac <mac-address>
- disassociate mac address from your usergimme macs
- list what mac adresses are associated with your userhookup playlist <spotify playlist uri>
- associate a spotify playlis with your userlist songs
- get a list of all songs currently in the collaborative playlist
These commands can be issued in any channel Hubot is setup to be listening to.
play music
pause music
next song
haddaway
hotshot
Happy playing!!!