Skip to content

domwong/spotify-playlist-saver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotify Playlist Saver

The Discover Weekly playlist on Spotify is pretty awesome, but it gets updated every week so you unless you save all the songs you lose those hidden gems. This is a toy project to automatically and regularly save Spotify playlists. There is an existing IFTTT integration but I wanted to flex my coding chops and try out some things on AWS.

Architecture

Consists of:

  • Three AWS lambdas
    • root - a simple redirect which kicks off the auth flow.
    • callback - which does the OAuth dance, retrieving the OAuth token and storing in DynamoDB for subsequent operations.
    • save - which does the actual saving of the playlist. Configure a cloudwatch cron job to run it once a week.
  • A DynamoDB table
  • Some cloud watch rules to schedule weekly saving

Usage

Hit the root / endpoint, which will redirect you to Spotify to login and authorise the app. Once you've authorised the app you should see a success message. This will schedule a weekly back up of Discover Weekly, the first one will happen in 2 minutes from when you invoke the app.

Build and Deploy

  1. Create DynamoDB table spotify with username as primary key
  2. Run build.sh to build and deploy the lambda code to AWS.
  3. Create API gateway definition
    1. Point / to root
    2. Point /callback to callback and add query string parameters code, state, and error
  4. Deploy the API
  5. Update lambdas with env variables
    1. REDIRECT_URI - this is the API Gateway url to the /callback endpoint
    2. SPOTIFY_ID - the client ID from Spotify
    3. SPOTIFY_SECRET - the client secret from Spotify
  6. Create an IAM role for the lambdas to run under. They need to
    1. Create new cloud watch rules
    2. Read and write to dynamo db
    3. Write logs to cloud watch

TODO

  • Add support for the state parameter to fix security hole

About

Saving my discover weekly playlist every week

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published