chore: Prettified Code
[ci skip]
This commit is contained in:
parent
9eea5d3561
commit
5c1e40cf88
1 changed files with 10 additions and 10 deletions
|
@ -82,30 +82,30 @@ const MusicKitInterop = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchPrimaryArtist() {
|
async fetchPrimaryArtist() {
|
||||||
const songID = app.mk.nowPlayingItem.attributes.playParams.catalogId || app.mk.nowPlayingItem.attributes.playParams.id
|
const songID = app.mk.nowPlayingItem.attributes.playParams.catalogId || app.mk.nowPlayingItem.attributes.playParams.id;
|
||||||
const res = await MusicKit.getInstance().api.v3.music("/v1/catalog/" + MusicKit.getInstance().storefrontId + `/songs/${songID}`, {
|
const res = await MusicKit.getInstance().api.v3.music("/v1/catalog/" + MusicKit.getInstance().storefrontId + `/songs/${songID}`, {
|
||||||
include: {
|
include: {
|
||||||
songs: ["artists"]
|
songs: ["artists"],
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
if (!res || !res.data) {
|
if (!res || !res.data) {
|
||||||
console.warn("[cider:preload] fetchPrimaryArtist: no response");
|
console.warn("[cider:preload] fetchPrimaryArtist: no response");
|
||||||
return app.mk.nowPlayingItem.attributes.artistName;
|
return app.mk.nowPlayingItem.attributes.artistName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res.data.data.length) {
|
if (!res.data.data.length) {
|
||||||
console.error(`[cider:preload] fetchPrimaryArtist: Unable to locate song with id of ${songID}`)
|
console.error(`[cider:preload] fetchPrimaryArtist: Unable to locate song with id of ${songID}`);
|
||||||
return app.mk.nowPlayingItem.attributes.artistName;
|
return app.mk.nowPlayingItem.attributes.artistName;
|
||||||
}
|
}
|
||||||
const songData = res.data.data[0]
|
const songData = res.data.data[0];
|
||||||
const artistData = songData.relationships.artists.data
|
const artistData = songData.relationships.artists.data;
|
||||||
if (artistData.length < 1) {
|
if (artistData.length < 1) {
|
||||||
console.error(`[cider:preload] fetchPrimaryArtist: Unable to find artists related to the song with id of ${songID}`)
|
console.error(`[cider:preload] fetchPrimaryArtist: Unable to find artists related to the song with id of ${songID}`);
|
||||||
return app.mk.nowPlayingItem.attributes.artistName;
|
return app.mk.nowPlayingItem.attributes.artistName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryArtist = artistData[0]
|
const primaryArtist = artistData[0];
|
||||||
return primaryArtist.attributes.name
|
return primaryArtist.attributes.name;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAttributes: function () {
|
getAttributes: function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue