Merge branch 'main' into developer
This commit is contained in:
commit
6c5f9f5498
14
package-lock.json
generated
14
package-lock.json
generated
@ -6,7 +6,7 @@
|
|||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^16.9.4",
|
"@types/node": "^16.9.4",
|
||||||
@ -17,9 +17,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "16.9.4",
|
"version": "16.10.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.1.tgz",
|
||||||
"integrity": "sha512-KDazLNYAGIuJugdbULwFZULF9qQ13yNWEBFnfVpqlpgAAo6H/qnM9RjBgh0A0kmHf3XxAKLdN5mTIng9iUvVLA==",
|
"integrity": "sha512-4/Z9DMPKFexZj/Gn3LylFgamNKHm4K3QDi0gz9B26Uk0c8izYf97B5fxfpspMNkWlFupblKM/nV8+NA9Ffvr+w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
@ -37,9 +37,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "16.9.4",
|
"version": "16.10.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.1.tgz",
|
||||||
"integrity": "sha512-KDazLNYAGIuJugdbULwFZULF9qQ13yNWEBFnfVpqlpgAAo6H/qnM9RjBgh0A0kmHf3XxAKLdN5mTIng9iUvVLA==",
|
"integrity": "sha512-4/Z9DMPKFexZj/Gn3LylFgamNKHm4K3QDi0gz9B26Uk0c8izYf97B5fxfpspMNkWlFupblKM/nV8+NA9Ffvr+w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
|
|||||||
@ -102,33 +102,35 @@ export function authorization(): void {
|
|||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout
|
output: process.stdout
|
||||||
});
|
});
|
||||||
ask.question('SoundCloud/ Spotify (so/sp) : ', (msg) => {
|
ask.question('Choose your service - sc (for SoundCloud) / sp (for Spotify) : ', (msg) => {
|
||||||
if (msg.toLowerCase().startsWith('sp')) {
|
if (msg.toLowerCase().startsWith('sp')) {
|
||||||
let client_id: string, client_secret: string, redirect_url: string, market: string;
|
let client_id: string, client_secret: string, redirect_url: string, market: string;
|
||||||
ask.question('Client ID : ', (id) => {
|
ask.question('Start by entering your Client ID : ', (id) => {
|
||||||
client_id = id;
|
client_id = id;
|
||||||
ask.question('Client Secret : ', (secret) => {
|
ask.question('Now enter your Client Secret : ', (secret) => {
|
||||||
client_secret = secret;
|
client_secret = secret;
|
||||||
ask.question('Redirect URL : ', (url) => {
|
ask.question('Enter your Redirect URL now : ', (url) => {
|
||||||
redirect_url = url;
|
redirect_url = url;
|
||||||
console.log(
|
console.log(
|
||||||
'\nMarket Selection URL : \nhttps://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements \n'
|
'\nIf you would like to know your region code visit : \nhttps://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements \n'
|
||||||
);
|
);
|
||||||
ask.question('Market : ', (mar) => {
|
ask.question('Enter your region code (2-letter country code) : ', (mar) => {
|
||||||
if (mar.length === 2) market = mar;
|
if (mar.length === 2) market = mar;
|
||||||
else {
|
else {
|
||||||
console.log('Invalid Market, Selecting IN as market');
|
console.log(
|
||||||
|
"That doesn't look like a valid region code, IN will be selected as default."
|
||||||
|
);
|
||||||
market = 'IN';
|
market = 'IN';
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
'\nNow Go to your browser and Paste this url. Authroize it and paste the redirected url here. \n'
|
'\nNow open your browser and paste the below url, then authorize it and copy the redirected url. \n'
|
||||||
);
|
);
|
||||||
console.log(
|
console.log(
|
||||||
`https://accounts.spotify.com/authorize?client_id=${client_id}&response_type=code&redirect_uri=${encodeURI(
|
`https://accounts.spotify.com/authorize?client_id=${client_id}&response_type=code&redirect_uri=${encodeURI(
|
||||||
redirect_url
|
redirect_url
|
||||||
)} \n`
|
)} \n`
|
||||||
);
|
);
|
||||||
ask.question('Redirected URL : ', async (url) => {
|
ask.question('Paste the url which you just copied : ', async (url) => {
|
||||||
if (!fs.existsSync('.data')) fs.mkdirSync('.data');
|
if (!fs.existsSync('.data')) fs.mkdirSync('.data');
|
||||||
const spotifyData = {
|
const spotifyData = {
|
||||||
client_id,
|
client_id,
|
||||||
@ -138,33 +140,32 @@ export function authorization(): void {
|
|||||||
market
|
market
|
||||||
};
|
};
|
||||||
const check = await SpotifyAuthorize(spotifyData);
|
const check = await SpotifyAuthorize(spotifyData);
|
||||||
if (check === false) throw new Error('Failed to get access Token.');
|
if (check === false) throw new Error('Failed to get access token.');
|
||||||
ask.close();
|
ask.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (msg.toLowerCase().startsWith('so')) {
|
} else if (msg.toLowerCase().startsWith('sc')) {
|
||||||
let client_id: string;
|
let client_id: string;
|
||||||
ask.question('Client ID : ', async (id) => {
|
ask.question('Client ID : ', async (id) => {
|
||||||
client_id = id;
|
client_id = id;
|
||||||
if (!client_id) {
|
if (!client_id) {
|
||||||
console.log("You didn't provided Client ID. Try again");
|
console.log("You didn't provide a client ID. Try again...");
|
||||||
ask.close();
|
ask.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!fs.existsSync('.data')) fs.mkdirSync('.data');
|
if (!fs.existsSync('.data')) fs.mkdirSync('.data');
|
||||||
console.log('Checking Client ID...................');
|
console.log('Validating your client ID, hold on...');
|
||||||
if (await check_id(client_id)) {
|
if (await check_id(client_id)) {
|
||||||
console.log('Congratulations! Client ID is correct');
|
console.log('Client ID has been validated successfully.');
|
||||||
fs.writeFileSync('.data/soundcloud.data', JSON.stringify({ client_id }, undefined, 4));
|
fs.writeFileSync('.data/soundcloud.data', JSON.stringify({ client_id }, undefined, 4));
|
||||||
} else console.log('Client ID is incorrect. Try to run this again with correct client ID.');
|
} else console.log("That doesn't look like a valid client ID. Retry with a correct client ID.");
|
||||||
|
|
||||||
ask.close();
|
ask.close();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('Invalid Option, Please Try again');
|
console.log("That option doesn't exist. Try again...");
|
||||||
ask.close();
|
ask.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user