mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-01 12:46:07 +00:00
services/soundcloud: properly check script hostname
This commit is contained in:
parent
0fefc4ac27
commit
4daeaa3107
|
@ -12,17 +12,19 @@ async function findClientID() {
|
||||||
let scVersion = String(sc.match(/<script>window\.__sc_version="[0-9]{10}"<\/script>/)[0].match(/[0-9]{10}/));
|
let scVersion = String(sc.match(/<script>window\.__sc_version="[0-9]{10}"<\/script>/)[0].match(/[0-9]{10}/));
|
||||||
|
|
||||||
if (cachedID.version === scVersion) return cachedID.id;
|
if (cachedID.version === scVersion) return cachedID.id;
|
||||||
|
|
||||||
let scripts = sc.matchAll(/<script.+src="(.+)">/g);
|
let scripts = sc.matchAll(/<script.+src="(.+)">/g);
|
||||||
let clientid;
|
let clientid;
|
||||||
for (let script of scripts) {
|
for (let script of scripts) {
|
||||||
let url = script[1];
|
let url = script[1];
|
||||||
|
|
||||||
if (url && !url.startsWith('https://a-v2.sndcdn.com')) return;
|
if (!url?.startsWith('https://a-v2.sndcdn.com/')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let scrf = await fetch(url).then(r => r.text()).catch(() => {});
|
let scrf = await fetch(url).then(r => r.text()).catch(() => {});
|
||||||
let id = scrf.match(/\("client_id=[A-Za-z0-9]{32}"\)/);
|
let id = scrf.match(/\("client_id=[A-Za-z0-9]{32}"\)/);
|
||||||
|
|
||||||
if (id && typeof id[0] === 'string') {
|
if (id && typeof id[0] === 'string') {
|
||||||
clientid = id[0].match(/[A-Za-z0-9]{32}/)[0];
|
clientid = id[0].match(/[A-Za-z0-9]{32}/)[0];
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue