music: attempt to fix random errors with sc playlists

This commit is contained in:
Cynthia Foxwell 2022-04-24 12:09:39 -06:00
parent 4bcb64d104
commit b3444b16e1

View file

@ -84,9 +84,16 @@ async function processPlaylist(
const clientId = await getSoundcloudClientID();
if (url.indexOf("/likes") > -1) {
const userInfo = await fetch(
let userInfo = await fetch(
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
).then((res) => res.json());
while (!userInfo.uri) {
userInfo = await fetch(
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
).then((res) => res.json());
}
const likesUrl =
userInfo.uri.replace("api.", "api-v2.") +
"/likes?limit=500&client_id=" +
@ -171,6 +178,8 @@ async function enqueue(
addedBy,
suppress = false
) {
if (!url) return;
const connection =
voiceStorage.get(guild_id) ??
(await createVoiceConnection(guild_id, voice_id, text_id));
@ -205,7 +214,8 @@ async function enqueue(
highWaterMark: 1 << 25,
});
} else if (type == "sc") {
url = url.replace(/^sc:/, "https://soundcloud.com/");
if (url.startsWith("sc:"))
url = url.replace(/^sc:/, "https://soundcloud.com/");
const client_id = await getSoundcloudClientID();
const info = await fetch(