Solves a famous Spotify shuffle issue, where only a handful of songs from the start of playlist is being shuffled:
- https://community.spotify.com/t5/Desktop-Mac/Shuffle-repeats-songs-too-often/td-p/22413
- https://www.saintlad.com/spotify-shuffle-play-is-not-random/
- https://www.independent.co.uk/life-style/gadgets-and-tech/news/why-random-shuffle-feels-far-from-random-10066621.html
- many nore
It setups multiple AWS functions:
- Used to login to Spotify (only needed once to authorize access and retrieve token)
- Used for authorization callback to save token in the DynamoDB
- Used to refresh token (runs every 59 minutes)
- Used to actually shuffle songs around playlist (run every 1 minute)
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.
- Node.js and NPM.
- Serverless.
- AWS CLI installed and configured.
git clone [email protected]:Napas/spotify-randomizer.git
cd spotify-randomizer
npm install
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)
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.
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.
Don't order playlists in a Spotify player after they were randomized as it will wipe away all the good work.
This work is licensed under a Creative Commons Attribution 4.0 International License.