mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-24 03:58:49 +01:00
api/soundcloud: catch region locked and paid songs and show an error
This commit is contained in:
parent
eb52ab2be8
commit
43c3294230
1 changed files with 15 additions and 1 deletions
|
@ -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…
Reference in a new issue