mirror of
https://codeberg.org/lucida/lucida.git
synced 2026-11-12 06:37:49 -05:00
add on.soundcloud.com support, bump version
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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<GetByUrlResponse> {
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user