Skip to content

Napas/spotify-randomizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotify Playlist Randomizer

Solves a famous Spotify shuffle issue, where only a handful of songs from the start of playlist is being shuffled:

Liked it? Buy me a beer :)

Donate

How does it work?

It setups multiple AWS functions:

  1. Used to login to Spotify (only needed once to authorize access and retrieve token)
  2. Used for authorization callback to save token in the DynamoDB
  3. Used to refresh token (runs every 59 minutes)
  4. Used to actually shuffle songs around playlist (run every 1 minute)

How much does it cost?

It's about $0.2 per month per playlist if you are out of free tier, if not multiple playlist can be shuffled for free.

Great - how do I use it?

0. Prerequisites

1. Installation

git clone [email protected]:Napas/spotify-randomizer.git
cd spotify-randomizer
npm install

2. Configuration

Go to https://developer.spotify.com/dashboard/applications register as a developer and create a new application.

You should get a client id and client secret tokens, which should be set in the serverless.yml under provider.environment.SPOTIFY_CLIENT_ID and provider.environment.SPOTIFY_CLIENT_SECRET.

Go to https://open.spotify.com and select a playlist you want to shuffle, there should be an id in the url, which you need to set in the serverless.yml under functions.shuffle.environment.PLAYLIST_ID.

Multiple playlist can be shuffled by configuring multiple shuffle functions:

  shuffle1:
    handler: handler.shuffle
    environment:
      PLAYLIST_ID: "playlist_id_1"
    events:
      - schedule:
          rate: rate(1 minute)
  shuffle2:
    handler: handler.shuffle
    environment:
      PLAYLIST_ID: "playlist_id_2"
    events:
      - schedule:
          rate: rate(1 minute)

3. Deploying

Simple as bash sls deploy

It will output 2 urls:

endpoints:
  GET - https://random-string.execute-api.eu-west-1.amazonaws.com/prod/login
  GET - https://random-string.execute-api.eu-west-1.amazonaws.com/prod/callback

go to the first one - https://random-string.execute-api.eu-west-1.amazonaws.com/prod/login .

It will redirect to the Spotify asking to login and give permissions to for the application to modify your playlists.

4. Profit

Now every minute lambda function will take between 1% and 100 (that's Spotify limit) songs and move them to a random place in the playlist.

Depending on a playlist size it will take some time for it to become completely random - I would give it a day or so but you'll start to notice effects pretty soon.

Gotchas

Don't order playlists in a Spotify player after they were randomized as it will wipe away all the good work.

License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published