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

Function fetchAndPlay

Extensions/shuffle+.js:588–654  ·  view source on GitHub ↗
(rawUri)

Source from the content-addressed store, hash-verified

586 }
587
588 async function fetchAndPlay(rawUri) {
589 let list;
590 let context;
591 let type = null;
592 let uri;
593
594 try {
595 if (rawUri === "queue") {
596 list = fetchQueue();
597 context = null;
598 } else if (typeof rawUri === "object") {
599 list = rawUri;
600 context = null;
601 } else {
602 const uriObj = Spicetify.URI.fromString(rawUri);
603 type = uriObj.type;
604 uri = uriObj._base62Id ?? uriObj.id;
605
606 switch (type) {
607 case Type.PLAYLIST:
608 case Type.PLAYLIST_V2:
609 list = await fetchPlaylistTracks(uri);
610 break;
611 case Type.ALBUM:
612 list = await fetchAlbumTracks(rawUri);
613 break;
614 case `${Type.ARTIST}`:
615 if (CONFIG.artistMode === "likedSongArtist") {
616 list = await fetchArtistLikedTracks(uri);
617 break;
618 }
619 if (CONFIG.artistMode === "topTen") {
620 list = await fetchArtistTopTenTracks(rawUri);
621 break;
622 }
623 list = await fetchArtistTracks(rawUri);
624 break;
625 case Type.TRACK:
626 case Type.LOCAL_TRACK:
627 case Type.COLLECTION:
628 list = await fetchCollection(uriObj);
629 break;
630 case Type.FOLDER:
631 list = await fetchFolderTracks(rawUri);
632 break;
633 case Type.SHOW:
634 list = await fetchShows(uri);
635 break;
636 }
637
638 if (!list?.length) {
639 Spicetify.showNotification("Nothing to play", true);
640 return;
641 }
642
643 context = rawUri;
644 if (type === "folder" || type === "collection" || type === "local") {
645 context = null;

Callers 2

shuffle+.jsFile · 0.85
renderQueuePlaybarButtonFunction · 0.85

Calls 11

fetchQueueFunction · 0.85
fetchPlaylistTracksFunction · 0.85
fetchAlbumTracksFunction · 0.85
fetchArtistLikedTracksFunction · 0.85
fetchArtistTopTenTracksFunction · 0.85
fetchArtistTracksFunction · 0.85
fetchCollectionFunction · 0.85
fetchFolderTracksFunction · 0.85
fetchShowsFunction · 0.85
QueueFunction · 0.85
shuffleFunction · 0.85

Tested by

no test coverage detected