From 52893fd615770d3d3c825f072e59c08bdaaa0c22 Mon Sep 17 00:00:00 2001 From: aria blue Date: Thu, 11 Apr 2024 13:30:06 -0400 Subject: [PATCH] fix soundcloud bug --- run.js | 11 +++++++++++ src/streamers/soundcloud/main.ts | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 run.js diff --git a/run.js b/run.js new file mode 100644 index 0000000..e460a60 --- /dev/null +++ b/run.js @@ -0,0 +1,11 @@ +import Lucida from './build/index.js'; +import Soundcloud from './build/streamers/soundcloud/main.js' + +const lucida = new Lucida({ + modules: { + soundcloud: new Soundcloud({"oauthToken": "2-294707-1346470389-4thCm1p3QnA05"}) + }, + logins: {} +}); + +console.log(await lucida.search("ram ranch")) \ No newline at end of file diff --git a/src/streamers/soundcloud/main.ts b/src/streamers/soundcloud/main.ts index af95968..94cdfb0 100644 --- a/src/streamers/soundcloud/main.ts +++ b/src/streamers/soundcloud/main.ts @@ -55,11 +55,10 @@ export default class Soundcloud implements Streamer { if (!response.ok) { const errMsg = await response.text() try { - console.error('Soundcloud error response:', JSON.parse(errMsg)) + throw new Error(JSON.parse(errMsg)) } catch (error) { - console.error('Soundcloud error response:', errMsg) + throw new Error(errMsg); } - throw new Error(`Searching Soundcloud failed with status code ${response.status}.`) } const resultResponse = await response.json() @@ -233,7 +232,8 @@ async function fetchKey(response: string) { if (typeof streamKey == 'string') continue const key = keys[i].split(`"`)[0] - if (!key.startsWith('https://a-v2.sndcdn.com/assets/50-')) continue + const keyregex = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/ + if (!keyregex.test(key)) continue const script = await (await fetch(key)).text() if (script.split(`,client_id:"`).length > 1 && !streamKey) {