Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "chore: remove buttons" #117

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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