Skip to content

Commit

Permalink
Fix New Releases custom app for Spotify 1.1.81+
Browse files Browse the repository at this point in the history
- Based on proposed fix for `Shuffle+` (spicetify#1559)
- Fixes spicetify#1539 spicetify#1530 

Notes:
- Can probably be written nicer - this is my scuffed attempt to fix it
- May or may not actually show all new releases for all followed artists - have over 665 of them but I don't think I'm getting all of them (see below)
- May or may not return `error 500` (added `.catch()` block keeps it from breaking whole custom app)
  • Loading branch information
th3an7 authored Mar 29, 2022
1 parent eb3adee commit dfa29b9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions CustomApps/new-releases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ async function getArtistList() {
}

async function getArtistEverything(artist) {
const uid = artist.link.replace("spotify:artist:", "");
const body = await CosmosAsync.get(`hm://artist/v3/${uid}/desktop/entity?format=json`);
const releases = body?.releases;
const uid = artist.link;
const body = await CosmosAsync.get(`https://api-partner.spotify.com/pathfinder/v1/query?operationName=queryArtistOverview&variables=%7B%22uri%22%3A%22${uid}%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22433e28d1e949372d3ca3aa6c47975cff428b5dc37b12f5325d9213accadf770a%22%7D%7D`);
const releases = body?.data?.artist;
const items = [];
const types = [
[CONFIG.album, releases?.albums?.releases, Spicetify.Locale.get("album")],
[CONFIG["appears-on"], releases?.appears_on?.releases, Spicetify.Locale.get("artist.appears-on")],
[CONFIG.compilations, releases?.compilations?.releases, Spicetify.Locale.get("compilation")],
[CONFIG["single-ep"], releases?.singles?.releases, Spicetify.Locale.get("single") + "/" + Spicetify.Locale.get("ep")],
[CONFIG.album, releases?.discography?.albums?.items.map((item) => item.releases.items[0]), Spicetify.Locale.get("album")],
[CONFIG["appears-on"], releases?.relatedContent?.appearsOn?.items.map((item) => item.releases.items[0]), Spicetify.Locale.get("artist.appears-on")],
[CONFIG.compilations, releases?.discography?.compilations?.items.map((item) => item.releases.items[0]), Spicetify.Locale.get("compilation")],
[CONFIG["single-ep"], releases?.discography?.singles?.items.map((item) => item.releases.items[0]), Spicetify.Locale.get("single") + "/" + Spicetify.Locale.get("ep")],
];
for (const type of types) {
if (type[0] && type[1]) {
Expand Down Expand Up @@ -264,7 +264,7 @@ async function getPodcastRelease(uri) {
}

function metaFromTrack(artist, track) {
const time = new Date(track.year, track.month - 1, track.day);
const time = new Date(track.date.year, track.date.month - 1, track.date.day);
if (today - time.getTime() < limitInMs) {
return {
uri: track.uri,
Expand All @@ -273,9 +273,9 @@ function metaFromTrack(artist, track) {
name: artist.name,
uri: artist.link,
},
imageURL: track.cover.uri,
imageURL: track.coverArt.sources[2].url,
time,
trackCount: track.track_count,
trackCount: track.tracks.totalCount,
};
}
return null;
Expand All @@ -287,7 +287,7 @@ async function fetchTracks() {
const requests = artistList.map(async (obj) => {
const artist = obj.artistMetadata;

return await getArtistEverything(artist);
return await getArtistEverything(artist).catch(() => {});
});

return await Promise.all(requests);
Expand Down

0 comments on commit dfa29b9

Please sign in to comment.