MCPcopy
hub / github.com/spicetify/cli / fetchFolderTracks

Function fetchFolderTracks

Extensions/shuffle+.js:318–340  ·  view source on GitHub ↗
(uri)

Source from the content-addressed store, hash-verified

316 }
317
318 async function fetchFolderTracks(uri) {
319 const res = await Spicetify.Platform.RootlistAPI.getContents();
320
321 const requestFolder = searchFolder(res.items, uri);
322 if (!requestFolder) throw "Cannot find folder";
323
324 const requestPlaylists = [];
325 async function fetchNested(folder) {
326 if (!folder.items) return;
327
328 for (const i of folder.items) {
329 if (i.type === "playlist") {
330 const uriObj = Spicetify.URI.fromString(i.uri);
331 const uri = uriObj._base62Id ?? uriObj.id;
332 requestPlaylists.push(await fetchPlaylistTracks(uri));
333 } else if (i.type === "folder") await fetchNested(i);
334 }
335 }
336
337 await fetchNested(requestFolder);
338
339 return requestPlaylists.flat();
340 }
341
342 async function fetchAlbumTracks(uri, includeMetadata = false) {
343 const { queryAlbumTracks } = Spicetify.GraphQL.Definitions;

Callers 1

fetchAndPlayFunction · 0.85

Calls 2

searchFolderFunction · 0.85
fetchNestedFunction · 0.85

Tested by

no test coverage detected