diff --git a/package.json b/package.json index ac4a343..d609e88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lucida", - "version": "2.0.0-26", + "version": "2.0.0-27", "description": "A modular music downloader tool", "main": "build/index.js", "type": "module", diff --git a/src/streamers/soundcloud/main.ts b/src/streamers/soundcloud/main.ts index e90b528..d121ff1 100644 --- a/src/streamers/soundcloud/main.ts +++ b/src/streamers/soundcloud/main.ts @@ -57,7 +57,7 @@ interface SoundCloudSubscriptionData { } export default class Soundcloud implements Streamer { - hostnames = ['soundcloud.com', 'm.soundcloud.com', 'www.soundcloud.com'] + hostnames = ['soundcloud.com', 'm.soundcloud.com', 'www.soundcloud.com', 'on.soundcloud.com'] testData = { 'https://soundcloud.com/saoirsedream/charlikartlanparty': { type: 'track', @@ -144,6 +144,9 @@ export default class Soundcloud implements Streamer { } async getByUrl(url: string): Promise { + const { hostname } = new URL(url) + + if (hostname == 'on.soundcloud.com') url = await followRedirect(url) return await this.#getMetadata(url) } @@ -355,3 +358,12 @@ async function getStream( } } } + +async function followRedirect(url: string) { + const res = await fetch(url, { redirect: 'manual' }) + const location = res.headers.get('Location') + + if (res.status != 302 || !location) throw new Error('URL not supported') + + return location +}