GithubHelp home page GithubHelp logo

walt-grover's Introduction

walt-grover

Automatically update Slack status with current Spotify track.

Spotify Authentication

In order to access the Spotify API you must generate a proper OAuth token following the Spotify Authorizataion Guide.

This repository contains a simple callback script to generate a Refresh Token from the Spotify OAuth API which is required in the walt-grover.rb script to continually generate a fresh OAuth token.

Before building and running the container, you must create a Spotify App on the developer dashboard,

Copy the Client ID and Client Secret for the Spotify App as these are needed when running the container.

Set the Redirect URIs to http://localhost:9292/callback in the Spotify App settings, this must match exactly or the callback will not work.

Generating Spotify Refresh Token Using Callback

The callback container is only needed once in order to generate a refresh_token and only needed unless the refresh_token has expired.

Build the callback image from Dockerfile.callback,

docker build -f Dockerfile.callback -t callback .

Run the callback on localhost on port 9292 passing the CLIENT_ID and CLIENT_SECRET generated previously,

docker run -it --rm -e CLIENT_ID=*YOURCLIENTID* -e CLIENT_SECRET=*YOURCLIENTSECRET* -p 9292:9292 callback

In a web borwser go to http://localhost:9292 and click the login with spotify link. Authenticate with Spotify and a page with an access_token and refresh_token will generate. The refresh_token is used when running the waltgrover container to update Slack status.

Setting Slack Status to Current Spotify Track

Requires

  • Slack Personal API Token
  • Spotify client_id and client_secret - generated from Spotify App Dashboard
  • Spotify refresh_token - generated from callback container
  • Default status, emoji, and music emoji to use

Update the .env.example file in this repository with your Spotify, Slack, and other configurations, and copy to .env for the container to use as it's configuration.

Example .env file,

CLIENT_ID=*YOURSPOTIFYCLIENTID*
CLIENT_SECRET=*YOURSPOTIFYCLIENTSECRET*
REFRESH_TOKEN=*YOURSPOTIFYREFRESHTOKEN*
SLACK_PERSONAL_TOKEN=*YOURSLACKTOKEN*
DEFAULT_STATUS="Nothing currently playing"
DEFAULT_EMOJI=":speech_balloon:"
MUSIC_EMOJI=":musical_note:"

Build the waltgrover image from Dockerfile,

docker build -t waltgrover .

Run the waltgrover container by passing a .env file with required configuration,

docker run -it --rm --env-file=.env waltgrover

The container queries the Spotify API and sets Slack status to the current playing track every 3 minutes, if nothing is playing, a default status and emoji are set based on the DEFAULT_STATUS and DEFAULT_EMOJI env vars.

Example container output,

[Mar 09 07:02:46.37] Starting up...
-------------------------
Successfuly updated Slack
status: Massive Attack - Unfinished Sympathy - 2012 Mix/Master
emoji: :musical_note:
response code: 200
response message: OK
Sleeping for 180 seconds...
-------------------------
Successfuly updated Slack
status: The Raconteurs - Salute Your Solution
emoji: :musical_note:
response code: 200
response message: OK
Sleeping for 180 seconds...
-------------------------
Successfuly updated Slack
status: The Rentals - My Head Is In The Sun
emoji: :musical_note:
response code: 200
response message: OK
Sleeping for 180 seconds...
-------------------------
Successfuly updated Slack
status: Nothing currently playing
emoji: :speech_balloon:
response code: 200
response message: OK
Sleeping for 180 seconds...
-------------------------

walt-grover's People

Contributors

ecliptik avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.