mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-28 20:40:12 +02:00
api/soundcloud: catch region locked and paid songs and show an error
This commit is contained in:
parent
eb52ab2be8
commit
43c3294230
@ -62,7 +62,17 @@ export default async function(obj) {
|
||||
|
||||
if (!json) return { error: "fetch.fail" };
|
||||
|
||||
if (!json.media.transcodings) return { error: "fetch.empty" };
|
||||
if (json?.policy === "BLOCK") {
|
||||
return { error: "content.region" };
|
||||
}
|
||||
|
||||
if (json?.policy === "SNIP") {
|
||||
return { error: "content.paid" };
|
||||
}
|
||||
|
||||
if (!json?.media?.transcodings || !json?.media?.transcodings.length === 0) {
|
||||
return { error: "fetch.empty" };
|
||||
}
|
||||
|
||||
let bestAudio = "opus",
|
||||
selectedStream = json.media.transcodings.find(v => v.preset === "opus_0_0"),
|
||||
@ -74,6 +84,10 @@ export default async function(obj) {
|
||||
bestAudio = "mp3"
|
||||
}
|
||||
|
||||
if (!selectedStream) {
|
||||
return { error: "fetch.empty" };
|
||||
}
|
||||
|
||||
let fileUrlBase = selectedStream.url;
|
||||
let fileUrl = `${fileUrlBase}${fileUrlBase.includes("?") ? "&" : "?"}client_id=${clientId}&track_authorization=${json.track_authorization}`;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user