artist clicking fallback to primary artist if multiple artists
This commit is contained in:
parent
6a4346028e
commit
23a889e11a
2 changed files with 13 additions and 4 deletions
|
@ -83,7 +83,7 @@ const MusicKitInterop = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchPrimaryArtist() {
|
async fetchPrimaryArtist(returnType = "name") {
|
||||||
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: {
|
||||||
|
@ -107,7 +107,11 @@ const MusicKitInterop = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryArtist = artistData[0];
|
const primaryArtist = artistData[0];
|
||||||
return primaryArtist.attributes.name;
|
if (returnType === "name") {
|
||||||
|
return primaryArtist.attributes.name;
|
||||||
|
} else if (returnType === "id") {
|
||||||
|
return primaryArtist.id;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getAttributes: function () {
|
getAttributes: function () {
|
||||||
|
|
|
@ -4535,8 +4535,13 @@ const app = new Vue({
|
||||||
{
|
{
|
||||||
icon: "./assets/feather/user.svg",
|
icon: "./assets/feather/user.svg",
|
||||||
name: app.getLz("action.goToArtist"),
|
name: app.getLz("action.goToArtist"),
|
||||||
action: function () {
|
action: async function () {
|
||||||
app.appRoute(`artist/${app.mk.nowPlayingItem.relationships.artists.data[0].id}`);
|
if (app.mk.nowPlayingItem.relationships.artists.data[0].id) {
|
||||||
|
app.appRoute(`artist/${app.mk.nowPlayingItem.relationships.artists.data[0].id}`);
|
||||||
|
} else {
|
||||||
|
const id = await MusicKitInterop.fetchPrimaryArtist("id")
|
||||||
|
app.appRoute(`artist/${id}`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue