A small side-project to automatically create/update Spotify playlists with songs played by my favorite radio station (as recorded by TuneGenie).
It currently supports two modes of operation:
- Top Hits (whatever TuneGenie lists as the most-popular songs)
- On Air (all tracks played in the last
x
hours)
This was created for my personal/educational use only. There are several issues and incomplete features which may never be fully implemented. Hopefully someone else may find the code useful though.
Please also see the LICENSE
.
You'll need to npm install
as usual.
Copy config.example.json
to config.json
and update the CHANGEME
fields accordingly.
OAuth2 is only partially implemented - you'll need to manually generate the grant code and obtain the initial access & refresh tokens yourself:
- Register a new application in Spotify. Set the
clientId
andclientSecret
values inconfig.json
accordingly. - Create a fake
redirectUri
. Pop that into bothconfig.json
and the Spotify app configuration. - Run this app. You'll get an error like
Authentication required: visit http://someurl.com
. Go there. - Once you complete step 3, you'll get redirected to that fake URL. It will contain a code. You'll need to copy that and manually run code like this to obtain the tokens using that code.
- Save the resulting
accessToken
andrefreshToken
toconfig.json
.
This tool should automatically handle refreshing the token as needed (barely tested). The manual process above is currently required because A) I'm lazy, and B) it requires a public-facing web-app, which this tool isn't. Perhaps one day I'll figure out a better solution...
You can configure any number of playlists. Each one requires the following fields:
name
- The name of the playlist (as you'd like it to appear in Spotifypublic
- Whether the playlist should be publically-visiblebrand
- The subdomain of tunegenie.com. So if you want data fromwbru.tunegenie.com
, set this towbru
type
- EithertopHits
oronAir
If the type
is onAir
, you'll also want to provide:
day
- Name of the last day to pull data for.hours
- Determines how far back in time (in hours) to look. More hours = more songs.
For example, if you want all songs played on a Friday, set day
to Friday
and hours
to 24
.
Upon creating the playlist, this tool will also add an additional configuration item:
playlistId
- The Spotify ID of the playlist; used to update the existing playlist on subsequent runs
The config file allows you to configure how certain songs should be handled. For example, if TuneGenie always mispells a certain track (causing it to not be found by Spotify), you can provide the correct spelling. Or perhaps you never want a certain song to be included - you can blacklist it from being added to your playlists. See the sample config file for examples of this.
Honestly, I've just been running app.coffee
from my IDE. There's a script in bin
which may (or may not) work - I haven't actually tested it.
Good luck and happy coding!