mirror of
https://codeberg.org/lucida/lucida.git
synced 2026-11-13 23:27:24 -05:00
add episodes/podcasts to spotify, fix soundcloud bugs
This commit is contained in:
@@ -141,18 +141,21 @@ export default class Soundcloud implements Streamer {
|
||||
switch (type) {
|
||||
case 'track': {
|
||||
const trackId = html
|
||||
.split(`{"hydratable":"sound",`)?.[1]
|
||||
?.split(`"id":`)?.[1]
|
||||
?.split(',')?.[0]
|
||||
.split(`<link rel="alternate" href="android-app://com.soundcloud.android/soundcloud/sounds:`)?.[1]
|
||||
?.split(`">`)?.[0]
|
||||
|
||||
let naked = `https://api-v2.soundcloud.com/tracks/${trackId}`
|
||||
let path = new URL(url).pathname
|
||||
if (path.split('/').length == 4) naked = `${naked}?secret_token=${path.split('/')[3]}`
|
||||
|
||||
const api = JSON.parse(
|
||||
await (
|
||||
await fetch(
|
||||
this.#formatURL(`https://api-v2.soundcloud.com/tracks?ids=${trackId}`, client),
|
||||
this.#formatURL(naked, client),
|
||||
{ method: 'get', headers: headers(this.oauthToken) }
|
||||
)
|
||||
).text()
|
||||
)[0]
|
||||
)
|
||||
|
||||
return {
|
||||
type: 'track',
|
||||
@@ -215,6 +218,8 @@ export default class Soundcloud implements Streamer {
|
||||
metadata: parseArtist(data)
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw(`Type "${type}" not supported.`)
|
||||
}
|
||||
}
|
||||
async #getRawTrackInfo(id: number | string, client: ScClient) {
|
||||
|
||||
@@ -81,10 +81,14 @@ export interface RawTrack {
|
||||
kind: 'track'
|
||||
id: number
|
||||
title: string
|
||||
duration: number,
|
||||
created_at: string,
|
||||
full_duration: number,
|
||||
permalink_url: string
|
||||
artwork_url?: string
|
||||
full_duration: number
|
||||
user: RawArtist
|
||||
artwork_url?: string,
|
||||
user: RawArtist,
|
||||
last_modified: string,
|
||||
description: string
|
||||
}
|
||||
|
||||
export async function parseTrack(raw: RawTrack): Promise<Track> {
|
||||
@@ -93,12 +97,12 @@ export async function parseTrack(raw: RawTrack): Promise<Track> {
|
||||
title: raw.title,
|
||||
url: raw.permalink_url,
|
||||
artists: [parseArtist(raw.user)],
|
||||
durationMs: raw.media?.transcodings?.[0]?.duration
|
||||
durationMs: (raw.full_duration || raw.media?.transcodings?.[0]?.duration),
|
||||
releaseDate: new Date(raw.created_at),
|
||||
description: raw.description
|
||||
}
|
||||
|
||||
if (raw?.artwork_url != undefined) {
|
||||
track.coverArtwork = [await parseCoverArtwork(raw?.artwork_url)]
|
||||
}
|
||||
if (raw?.artwork_url != undefined) track.coverArtwork = [await parseCoverArtwork(raw?.artwork_url)]
|
||||
|
||||
return track
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user