Skip to content

Commit

Permalink
chore: remove buttons
Browse files Browse the repository at this point in the history
looks like they are not supported by the "listening to" activity type
  • Loading branch information
NextFire committed Aug 29, 2024
1 parent e8b9b84 commit b5f8ee6
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions music-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function _getTrackExtras(
console.error("iTunes API error:", resp.statusText, url);

return {
artworkUrl: await _getMBArtwork(artist, song, album) ?? null,
artworkUrl: (await _getMBArtwork(artist, song, album)) ?? null,
iTunesUrl: null,
};
}
Expand Down Expand Up @@ -248,35 +248,13 @@ async function setActivity(rpc: Client): Promise<number> {

// album.length == 0 for radios
if (props.album.length > 0) {
const buttons = [];

const infos = await getTrackExtras(props);
console.log("infos:", infos);

activity.assets = {
large_image: infos.artworkUrl ?? "appicon",
large_text: formatStr(props.album),
};

if (infos.iTunesUrl) {
buttons.push({
label: "Play on Apple Music",
url: infos.iTunesUrl,
});
}

const query = encodeURIComponent(
`artist:${props.artist} track:${props.name}`
);
const spotifyUrl = `https://open.spotify.com/search/${query}?si`;
if (spotifyUrl.length <= 512) {
buttons.push({
label: "Search on Spotify",
url: spotifyUrl,
});
}

if (buttons.length > 0) activity.buttons = buttons;
}

await rpc.setActivity(activity);
Expand Down

0 comments on commit b5f8ee6

Please sign in to comment.