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) {