diff --git a/README.md b/README.md index 665618f..4525057 100644 --- a/README.md +++ b/README.md @@ -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)) -Screenshot 2024-08-29 at 20 05 10 + ## Getting Started diff --git a/music-rpc.ts b/music-rpc.ts index 9c2e0ec..316e3c0 100755 --- a/music-rpc.ts +++ b/music-rpc.ts @@ -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);