mirror of
https://git.gay/lucida/lucida
synced 2025-12-11 20:15:14 +01:00
add on.soundcloud.com support, bump version
This commit is contained in:
parent
c9c15f98b4
commit
43216bb2f2
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lucida",
|
"name": "lucida",
|
||||||
"version": "2.0.0-26",
|
"version": "2.0.0-27",
|
||||||
"description": "A modular music downloader tool",
|
"description": "A modular music downloader tool",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@ -57,7 +57,7 @@ interface SoundCloudSubscriptionData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class Soundcloud implements Streamer {
|
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 = {
|
testData = {
|
||||||
'https://soundcloud.com/saoirsedream/charlikartlanparty': {
|
'https://soundcloud.com/saoirsedream/charlikartlanparty': {
|
||||||
type: 'track',
|
type: 'track',
|
||||||
@ -144,6 +144,9 @@ export default class Soundcloud implements Streamer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getByUrl(url: string): Promise<GetByUrlResponse> {
|
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)
|
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
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user