soundcloud-key-fetch
Advanced tools
Comparing version 1.0.5 to 1.0.6
74
index.js
exports.fetchKey = async function() { | ||
return new Promise(async function(resolve, rej) { | ||
const fetch = require('node-fetch'); | ||
fetch(`https://soundcloud.com`).then(res => res.text()) | ||
.then(async r => { | ||
const res = r.split('<script crossorigin src="'); | ||
const urls = []; | ||
res.forEach(urlA => { | ||
const urlreg = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/ | ||
let url = urlA.replace('"></script>', ''); let res = url.split('\n')[0]; | ||
if(urlreg.test(res)) urls.push(res); | ||
}); | ||
async function fetchKey() { | ||
return new Promise(async function(resolve, rej) { | ||
let done = 0; let key; | ||
while(done !== urls.length && !key) { | ||
let url = urls[done]; | ||
done++; | ||
const a = await fetch(url); | ||
a.text().then(b => { | ||
if(b.includes(',client_id:"')) { | ||
const thingA = b.split(',client_id:"'); | ||
key = thingA[1].split('"')[0]; | ||
if(done === urls.length) return resolve(key) | ||
} | ||
}); | ||
}; | ||
}) | ||
} | ||
const key = await fetchKey() | ||
if(key) {resolve(key)} else {rej(`Key not found! (SoundCloud API changed?)`)} | ||
}).catch(e => { | ||
require('https').get('https://soundcloud.com/', (res) => { | ||
res.on('data', async (d) => { | ||
r = d.toString() | ||
const res = r.split('<script crossorigin src="'); | ||
const urls = []; | ||
res.forEach(urlA => { | ||
const urlreg = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/ | ||
let url = urlA.replace('"></script>', ''); let res = url.split('\n')[0]; | ||
if(urlreg.test(res)) urls.push(res); | ||
}); | ||
async function fetchKey() { | ||
return new Promise(async function(resolve, rej) { | ||
let done = 0; let key; | ||
while(done !== urls.length && !key) { | ||
let url = urls[done]; | ||
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) | ||
} | ||
}) | ||
}); | ||
}; | ||
}) | ||
} | ||
const key = await fetchKey() | ||
if(key) {resolve(key)} else {rej(`Key not found! (SoundCloud API changed?)`)} | ||
}) | ||
}).on('error', async e => { | ||
rej(e) | ||
@@ -41,9 +44,10 @@ }) | ||
if(!key) {return rej(`No API key provided`)} else { | ||
const fetch = require('node-fetch'); | ||
fetch(`https://api-v2.soundcloud.com/search?client_id=${key}&q=this%20package%20gave%20me%20neck%20pains&limit=0`).then(async result => { | ||
if(result.status === 401) return res(false); | ||
if(result.status === 404 || result.status === 200) return res(true) | ||
}).catch(e => {return rej(e)}) | ||
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 === 404 || result.statusCode === 200) return res(true) | ||
}).on('error', e => { | ||
return rej(e) | ||
}) | ||
} | ||
}) | ||
} |
{ | ||
"name": "soundcloud-key-fetch", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Fetch a SoundCloud API key without owning an app!", | ||
@@ -11,5 +11,3 @@ "main": "index.js", | ||
"license": "ISC", | ||
"dependencies": { | ||
"node-fetch": "^2.6.0" | ||
}, | ||
"dependencies": {}, | ||
"keywords": [ | ||
@@ -16,0 +14,0 @@ "soundcloud", |
# Soundcloud Key Fetch | ||
A simple module to fetch a SoundCloud API key without owning an application! | ||
A simple module to fetch a SoundCloud API key without owning an application, requiring no dependencies! | ||
``` | ||
@@ -4,0 +4,0 @@ npm i soundcloud-key-fetch |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
4571
0
69
- Removednode-fetch@^2.6.0
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)