Skip to content

JamesPRobinson/uk-gigs-to-spotify-playlists

Repository files navigation

uk-gigs-to-spotify-playlists

Overview

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:

Requirements

  • 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

Schemas

event_track Table Schema

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)

Constraints

  • 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.

uk_city_playlist Table Schema

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)

Constraints

  • unique_name_month_postcode: Ensures that the combination of month, name, and postcode is unique.

Implementation

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:

London- January

London- February

London- March

London- April

London- May

London- June

London- July

London- August

London- September

London- October

London- November

London- December

Cardiff- January

Cardiff- February

Cardiff- March

Cardiff- April

Cardiff- May

Cardiff- June

Cardiff- July

Cardiff- August

Cardiff- September

Cardiff- October

Cardiff- November

Cardiff- December

Leicester- January

Leicester- February

Leicester- March

Leicester- April

Leicester- May

Leicester- June

Leicester- July

Leicester- August

Leicester- September

Leicester- October

Leicester- November

Leicester- December

Liverpool- January

Liverpool- February

Liverpool- March

Liverpool- April

Liverpool- May

Liverpool- June

Liverpool- July

Liverpool- August

Liverpool- September

Liverpool- October

Liverpool- November

Liverpool- December

Manchester- January

Manchester- February

Manchester- March

Manchester- April

Manchester- May

Manchester- June

Manchester- July

Manchester- August

Manchester- September

Manchester- October

Manchester- November

Manchester- December

Inverness- January

Inverness- February

Inverness- March

Inverness- April

Inverness- May

Inverness- June

Inverness- July

Inverness- August

Inverness- September

Inverness- October

Inverness- November

Inverness- December

Newcastle upon Tyne- January

Newcastle upon Tyne- February

Newcastle upon Tyne- March

Newcastle upon Tyne- April

Newcastle upon Tyne- May

Newcastle upon Tyne- June

Newcastle upon Tyne- July

Newcastle upon Tyne- August

Newcastle upon Tyne- September

Newcastle upon Tyne- October

Newcastle upon Tyne- November

Newcastle upon Tyne- December

Belfast- January

Belfast- February

Belfast- March

Belfast- April

Belfast- May

Belfast- June

Belfast- July

Belfast- August

Belfast- September

Belfast- October

Belfast- November

Belfast- December

Plymouth- January

Plymouth- February

Plymouth- March

Plymouth- April

Plymouth- May

Plymouth- June

Plymouth- July

Plymouth- August

Plymouth- September

Plymouth- October

Plymouth- November

Plymouth- December

Edinburgh- January

Edinburgh- February

Edinburgh- March

Edinburgh- April

Edinburgh- May

Edinburgh- June

Edinburgh- July

Edinburgh- August

Edinburgh- September

Edinburgh- October

Edinburgh- November

Edinburgh- December

Milton Keynes- January

Milton Keynes- February

Milton Keynes- March

Milton Keynes- April

Milton Keynes- May

Milton Keynes- June

Milton Keynes- July

Milton Keynes- August

Milton Keynes- September

Milton Keynes- October

Milton Keynes- November

Milton Keynes- December

Brighton- January

Brighton- February

Brighton- March

Brighton- April

Brighton- May

Brighton- June

Brighton- July

Brighton- August

Brighton- September

Brighton- October

Brighton- November

Brighton- December

Leeds- January

Leeds- February

Leeds- March

Leeds- April

Leeds- May

Leeds- June

Leeds- July

Leeds- August

Leeds- September

Leeds- October

Leeds- November

Leeds- December

Sheffield- January

Sheffield- February

Sheffield- March

Sheffield- April

Sheffield- May

Sheffield- June

Sheffield- July

Sheffield- August

Sheffield- September

Sheffield- October

Sheffield- November

Sheffield- December

Birmingham- January

Birmingham- February

Birmingham- March

Birmingham- April

Birmingham- May

Birmingham- June

Birmingham- July

Birmingham- August

Birmingham- September

Birmingham- October

Birmingham- November

Birmingham- December

Bristol- January

Bristol- February

Bristol- March

Bristol- April

Bristol- May

Bristol- June

Bristol- July

Bristol- August

Bristol- September

Bristol- October

Bristol- November

Bristol- December

Glasgow- January

Glasgow- February

Glasgow- March

Glasgow- April

Glasgow- May

Glasgow- June

Glasgow- July

Glasgow- August

Glasgow- September

Glasgow- October

Glasgow- November

Glasgow- December

About

Create spotify playlists from events listings

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published