(uri)
| 382 | } |
| 383 | |
| 384 | async function fetchArtistTracks(uri) { |
| 385 | // Definitions from older Spotify version |
| 386 | const queryArtistOverview = { |
| 387 | name: "queryArtistOverview", |
| 388 | operation: "query", |
| 389 | sha256Hash: "35648a112beb1794e39ab931365f6ae4a8d45e65396d641eeda94e4003d41497", |
| 390 | value: null, |
| 391 | }; |
| 392 | const queryArtistDiscographyAll = { |
| 393 | name: "queryArtistDiscographyAll", |
| 394 | operation: "query", |
| 395 | sha256Hash: "9380995a9d4663cbcb5113fef3c6aabf70ae6d407ba61793fd01e2a1dd6929b0", |
| 396 | value: null, |
| 397 | }; |
| 398 | |
| 399 | const discography = await Spicetify.GraphQL.Request(queryArtistDiscographyAll, { |
| 400 | uri, |
| 401 | offset: 0, |
| 402 | // Limit 100 since GraphQL has resource limit |
| 403 | limit: 100, |
| 404 | }); |
| 405 | if (discography.errors) throw discography.errors[0].message; |
| 406 | |
| 407 | const overview = await Spicetify.GraphQL.Request(queryArtistOverview, { |
| 408 | uri, |
| 409 | locale: Spicetify.Locale.getLocale(), |
| 410 | includePrerelease: false, |
| 411 | }); |
| 412 | if (overview.errors) throw overview.errors[0].message; |
| 413 | |
| 414 | const artistName = overview.data.artistUnion.profile.name; |
| 415 | const releases = discography.data.artistUnion.discography.all.items.flatMap(({ releases }) => releases.items); |
| 416 | |
| 417 | const artistAlbums = releases.filter((album) => album.type === "ALBUM"); |
| 418 | const artistSingles = releases.filter((album) => album.type === "SINGLE" || album.type === "EP"); |
| 419 | |
| 420 | if (artistAlbums.length === 0 && artistSingles.length === 0) throw "Artist has no releases"; |
| 421 | |
| 422 | const allArtistAlbumsTracks = CONFIG.artistMode !== "single" ? await scanForTracksFromAlbums(artistAlbums, artistName, "album") : []; |
| 423 | const allArtistSinglesTracks = CONFIG.artistMode !== "album" ? await scanForTracksFromAlbums(artistSingles, artistName, "single") : []; |
| 424 | |
| 425 | return allArtistAlbumsTracks.concat(allArtistSinglesTracks); |
| 426 | } |
| 427 | |
| 428 | async function fetchArtistLikedTracks(uri) { |
| 429 | const artistRes = await Spicetify.CosmosAsync.get(`sp://core-collection/unstable/@/list/tracks/artist/${uri}?responseFormat=protobufJson`); |
no test coverage detected