Create spotify playlists from events listings.
ENTS24 API is hit with today's date and a postcode. These postcodes are taken by hand as a rough approx. of each city centre. Those listings are then taken to the Spotify API search function, the first song found by the artist is then added to that months' playlist.
The end result are playlists with the pattern {location}-{month}
.
An SQLite3 database keeps track of tracks with the schema:
- Spotify API credentials
- Ents24 API credentials
- Save credentials at root of project as
config.json
with structure:
{
"ents": {
"access_token": "", # https://developers.ents24.com/api-reference
"client_id": "",
"client_secret": ""
},
"spotify": {
"client_id": "", # https://developer.spotify.com/documentation/web-api
"client_secret": "",
"refresh_token": "" # https://developer.spotify.com/documentation/web-api/tutorials/refreshing-tokens
}
}
npm i
to install packages- Create a file called db/gigs_playlist.db
npm run bootstrap
to create the tables and spotify playlists
Column Name | Data Type | Constraints |
---|---|---|
event_track_id |
INTEGER | PRIMARY KEY |
uk_city_playlist_id |
INTEGER | NOT NULL, FOREIGN KEY (references uk_city_playlist(uk_city_playlist_id) ) |
artist_name |
TEXT | NOT NULL |
date_collected |
TEXT | NOT NULL |
end_date |
TEXT | |
genre |
TEXT | NOT NULL |
start_date |
TEXT | |
track_name |
TEXT | NOT NULL |
track_uri |
TEXT | NOT NULL |
web_link |
TEXT | |
venue_name |
TEXT | NOT NULL |
unique_track_artist_in_month_playlist |
UNIQUE (artist_name , uk_city_playlist_id , venue_name ) |
- unique_track_artist_in_month_playlist: Ensures that the combination of artist_name, track_uri, uk_city_playlist_id, and venue_name is unique.
- FOREIGN KEY(uk_city_playlist_id): Establishes a relationship with the uk_city_playlist table.
Column Name | Data Type | Constraints |
---|---|---|
uk_city_playlist_id |
INTEGER | PRIMARY KEY |
month |
TEXT | NOT NULL |
name |
TEXT | NOT NULL |
playlist_id |
TEXT | |
postcode |
TEXT | NOT NULL |
unique_name_month_postcode |
UNIQUE (month , name , postcode ) |
- unique_name_month_postcode: Ensures that the combination of month, name, and postcode is unique.
I've been running this as a CRON job on a raspberry pi with the idea that it is semi-autonomous (there's a need to refresh credentials from time-to-time, but this could also be automated) with tracks being added and then removed again when out-of-date. Streaming could be an option instead of CRON here.
See it in action here: