Simple tool that uses spotify and twitch api to automate song requests via custom rewards on twitch.
Leave a ⭐ if you like it :)
- You authorizing with twitch and spotify
- On first auth app will create custom reward and provide you with link to place where you can edit it
- Now users can redeem that reward, they must provide correct spotify url for single track, not playlist, not album or whatever!
- App will check if you have open spotify in any device then check for current playback state and depends on it it will add track to queue or instantly play it
- If error appear during song request (e.g. i'm bad programmer and made somewhere a mistake) app will automatically refund that redeem and user will get his points back
- If no error appear during song request app will automatically mark that redeem as successful
First of all you need spotify premium to use this program
You can only be able to add track to player queue via API only if you have spotify premium
- Download repo source code
- Download node 18.16 (I'm using nvm)
- Create .env file in root folder, fill it according to example file (.env.example)
3.1. For twitch client & secret thing visit: dashboard and create new application
3.2. For spotify client & secret thing visit: dashboard and create new application
3.3. IMPORTANT STEP! When creating those applications you need to add redirect url like this one:
For spotify:http://localhost:PORT-FROM-.ENV/spotify-auth
For twitch:http://localhost:PORT-FROM-.ENV/twitch-auth
- Create folder named data in root folder
- Install packages
npm i
oryarn
- Run
npm run run:compile && npm run run:ncc
oryarn run:compile && yarn run:ncc
That will create single js file in ncc folder that you can use to start application. It will be lightweight and easy to move - Make sure you have filled .env file and data folder besides newly created index js file
- Run it using node
node index.js
- Don't forget to open spotify when you start app
- Also you need to start listen to something for atleast 1 second on first spotify launch
Because i'm very bad at regexp i'm searching for someone who can write cool regexp to parse id from spotify url.
Id starts right after track/
and ending before ?si
Example url: https://open.spotify.com/track/1pKYYY0dkg23sQQXi0Q5zN?si=37729c4bbe63445b
It you want to help create regexp like that, or found a bug feel free to create issue of pull request with fix if you're not lazy to make one, much love 💌