mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-29 21:10:14 +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) 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",
|
let bestAudio = "opus",
|
||||||
selectedStream = json.media.transcodings.find(v => v.preset === "opus_0_0"),
|
selectedStream = json.media.transcodings.find(v => v.preset === "opus_0_0"),
|
||||||
@ -74,6 +84,10 @@ export default async function(obj) {
|
|||||||
bestAudio = "mp3"
|
bestAudio = "mp3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!selectedStream) {
|
||||||
|
return { error: "fetch.empty" };
|
||||||
|
}
|
||||||
|
|
||||||
let fileUrlBase = selectedStream.url;
|
let fileUrlBase = selectedStream.url;
|
||||||
let fileUrl = `${fileUrlBase}${fileUrlBase.includes("?") ? "&" : "?"}client_id=${clientId}&track_authorization=${json.track_authorization}`;
|
let fileUrl = `${fileUrlBase}${fileUrlBase.includes("?") ? "&" : "?"}client_id=${clientId}&track_authorization=${json.track_authorization}`;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user