soundcloud-key-fetch
Advanced tools
Comparing version 1.0.6 to 1.0.7
28
index.js
@@ -19,12 +19,14 @@ exports.fetchKey = async function() { | ||
done++; | ||
require('https').get(url, async a => { | ||
a.on('data', async d => { | ||
const b = d.toString() | ||
if(b.includes(',client_id:"')) { | ||
const thingA = b.split(',client_id:"'); | ||
key = thingA[1].split('"')[0]; | ||
if(done === urls.length) return resolve(key) | ||
} | ||
}) | ||
}); | ||
if(/(https:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/.test(url)) { | ||
require('https').get(url, async a => { | ||
a.on('data', async d => { | ||
const b = d.toString() | ||
if(b.includes(',client_id:"')) { | ||
const thingA = b.split(',client_id:"'); | ||
key = thingA[1].split('"')[0]; | ||
if(done === urls.length) return resolve(key) | ||
} | ||
}) | ||
}); | ||
} | ||
}; | ||
@@ -34,3 +36,3 @@ }) | ||
const key = await fetchKey() | ||
if(key) {resolve(key)} else {rej(`Key not found! (SoundCloud API changed?)`)} | ||
if(key) {resolve(key)} else {rej(new Error(`Unable to fetch a SoundCloud API key! This most likely has happened due to either making too many requests, or the SoundCloud website has changed!`))} | ||
}) | ||
@@ -45,5 +47,5 @@ }).on('error', async e => { | ||
return new Promise(function(res, rej) { | ||
if(!key) {return rej(`No API key provided`)} else { | ||
if(!key) {return rej(new Error(`No SoundCloud API key provided`))} else { | ||
require('https').get(`https://api-v2.soundcloud.com/search?client_id=${key}&q=this%20package%20gave%20me%20neck%20pains&limit=0`, async (result) => { | ||
if(result.statusCode === 401) return res(false); | ||
if(result.statusCode === 401 || result.statusCode === 403) return res(false); | ||
if(result.statusCode === 404 || result.statusCode === 200) return res(true) | ||
@@ -50,0 +52,0 @@ }).on('error', e => { |
{ | ||
"name": "soundcloud-key-fetch", | ||
"version": "1.0.6", | ||
"description": "Fetch a SoundCloud API key without owning an app!", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
"_from": "soundcloud-key-fetch", | ||
"_id": "soundcloud-key-fetch@1.0.6", | ||
"_inBundle": false, | ||
"_integrity": "sha512-/lrGW1kLhYTwmkmEdaO7/1apa6lwCy7qEZCnWceGKXRwQHFV0wK3s7gAg0kd6jvLoH4ON6AG7pMdFHjtsDibeQ==", | ||
"_location": "/soundcloud-key-fetch", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "tag", | ||
"registry": true, | ||
"raw": "soundcloud-key-fetch", | ||
"name": "soundcloud-key-fetch", | ||
"escapedName": "soundcloud-key-fetch", | ||
"rawSpec": "", | ||
"saveSpec": null, | ||
"fetchSpec": "latest" | ||
}, | ||
"author": "uwusyl", | ||
"license": "ISC", | ||
"_requiredBy": [ | ||
"#USER", | ||
"/" | ||
], | ||
"_resolved": "https://registry.npmjs.org/soundcloud-key-fetch/-/soundcloud-key-fetch-1.0.6.tgz", | ||
"_shasum": "224a174101a3ede8487242061c6273ac863cfee6", | ||
"_spec": "soundcloud-key-fetch", | ||
"_where": "/Users/sylqwq/Documents/key-fetch", | ||
"author": { | ||
"name": "uwusyl" | ||
}, | ||
"bundleDependencies": false, | ||
"dependencies": {}, | ||
"deprecated": false, | ||
"description": "Fetch a SoundCloud API key without owning an app!", | ||
"keywords": [ | ||
@@ -17,3 +38,10 @@ "soundcloud", | ||
"soundcloud key" | ||
] | ||
], | ||
"license": "ISC", | ||
"main": "index.js", | ||
"name": "soundcloud-key-fetch", | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"version": "1.0.7" | ||
} |
5840
71