(res, artistName, type)
| 358 | const artistFetchTypeCount = { album: 0, single: 0 }; |
| 359 | |
| 360 | async function scanForTracksFromAlbums(res, artistName, type) { |
| 361 | const allTracks = []; |
| 362 | |
| 363 | for (const album of res) { |
| 364 | let albumRes; |
| 365 | |
| 366 | try { |
| 367 | albumRes = await fetchAlbumTracks(album.uri, true); |
| 368 | } catch (error) { |
| 369 | console.error(album, error); |
| 370 | continue; |
| 371 | } |
| 372 | |
| 373 | artistFetchTypeCount[type]++; |
| 374 | Spicetify.showNotification(`${artistFetchTypeCount[type]} / ${res.length} ${type}s`); |
| 375 | |
| 376 | for (const track of albumRes) { |
| 377 | if (!CONFIG.artistNameMust || track.artists.items.some((artist) => artist.profile.name === artistName)) allTracks.push(track.uri); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | return allTracks; |
| 382 | } |
| 383 | |
| 384 | async function fetchArtistTracks(uri) { |
| 385 | // Definitions from older Spotify version |
no test coverage detected