music: fix /tracks for soundcloud
This commit is contained in:
parent
0ce0dfa67e
commit
77c73e814a
1 changed files with 25 additions and 0 deletions
|
@ -119,6 +119,31 @@ async function processPlaylist(
|
||||||
).then((res) => res.json());
|
).then((res) => res.json());
|
||||||
playlist = [...playlist, ...currentLikes.collection];
|
playlist = [...playlist, ...currentLikes.collection];
|
||||||
}
|
}
|
||||||
|
} else if (url.indexOf("/tracks")) {
|
||||||
|
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 tracksUrl =
|
||||||
|
userInfo.uri.replace("api.", "api-v2.") +
|
||||||
|
"/tracks?limit=500&client_id=" +
|
||||||
|
clientId;
|
||||||
|
|
||||||
|
let currentTracks = await fetch(tracksUrl).then((res) => res.json());
|
||||||
|
playlist = currentTracks.collection;
|
||||||
|
|
||||||
|
while (currentTracks.next_href != null) {
|
||||||
|
currentTracks = await fetch(
|
||||||
|
currentTracks.next_href + "&client_id=" + clientId
|
||||||
|
).then((res) => res.json());
|
||||||
|
playlist = [...playlist, ...currentTracks.collection];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
playlist = await fetch(
|
playlist = await fetch(
|
||||||
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
|
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${clientId}&limit=500`
|
||||||
|
|
Loading…
Reference in a new issue