Steps : -
-
Open your browser, then open dev-tools [ Option + ⌘ + J (on macOS), or Shift + CTRL + J (on Windows/Linux). ]
-
Go to any YouTube URL and find the first request and open it First Request :-
The first request would be watch?v="Your video ID"
-
Now just create a new file with this code :
const play = require('play-dl'); play.authorization();
And run this file. You will get a interface asking some question.
-
Go to Spotify Dashboard and create a new application or use old one.
-
Open that application. You will be given 2 things [ Client ID and Client Secret ( click on
Show Client Secret
to get info ) ]. Note these 2 things somewhere. -
Add this Redirect URI :
http://127.0.0.1/index.html
or any url according to you. [ Also note this somewhere ] -
Now create a
authorize.js
file and add this code :const play = require('play-dl'); play.authorization();
and run it
node authorize.js
-
You will be asked :-
- Saving INFO in file or not. [ If selected no, you will have to use
setToken
function after you get refresh-Token ] - Client ID
- Client Secret
- Redirect URI or Redirect URL
- Market [ Choose 2 letter code on left side of your country name from url ]
- You will be given a link for authorizing. Just paste it in your browser and click on authorize and copy the link that you are redirected to. [ Redirected Link should start with Redirect URI / Redirect URL that you have provided ]
- Paste the url in Redirected URL
- Saving INFO in file or not. [ If selected no, you will have to use
-
You have completed Authorization part. Now you can delete authorize js file.
You will notice that a folder named .data
has been created. Do not delete this, this contains all your spotify data. [ Only applicable if save in file is set to yes. ]
const play = require('play-dl')
play.getFreeClientID().then((clientID) => {
play.setToken({
soundcloud : {
client_id : clientID
}
})
})