Skip to content

Commit

Permalink
Revert "chore: remove buttons" (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire authored Nov 16, 2024
1 parent c429ac3 commit feb4a8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Works with local tracks and Apple Music streaming service.
- MusicBrainz artwork fallback
([#66](https://github.com/NextFire/apple-music-discord-rpc/pull/66))

<img width="350" alt="Screenshot 2024-08-29 at 20 05 10" src="https://github.com/user-attachments/assets/dbfd53ab-a958-431a-b2bc-34ea3e835d25">
<img width="284" src="https://github.com/user-attachments/assets/b9ff2727-ed47-4ba7-8c0a-6b3876715f71">

## Getting Started

Expand Down
24 changes: 24 additions & 0 deletions music-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ class AppleMusicDiscordRPC {
large_image: infos.artworkUrl ?? "appicon",
large_text: AppleMusicDiscordRPC.truncateString(props.album),
};

const buttons = [];

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 this.rpc.setActivity(activity);
Expand Down

0 comments on commit feb4a8f

Please sign in to comment.