Skip to content

Commit

Permalink
Better discord rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
arctixdev committed Feb 22, 2024
1 parent 2bb9b65 commit 6dbe587
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src-tauri/src/discord_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct Song {
album_image: String,
end: i64,
started: i64,
preview_url: String,
provider_url: String,
}

// Function for running the Discord rich presence
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn start_rpc(mass_ws: String, hostname: std::ffi::OsString) {
.clone()
.to_string()
.replace('"', ""),
preview_url: metadata["preview"].clone().to_string().replace('"', ""),
provider_url: media_item["provider_mappings"][0]["url"].clone().to_string().replace('"', ""),
artist_image: media_item["artists"][0]["metadata"]["images"][0]["path"]
.clone()
.to_string()
Expand Down Expand Up @@ -134,18 +134,18 @@ pub fn start_rpc(mass_ws: String, hostname: std::ffi::OsString) {
.end(current_song.end);

// The buttons of the activity
let buttons: Vec<activity::Button<'_>> = if current_song.preview_url.contains("https://") {
let buttons: Vec<activity::Button<'_>> = if current_song.provider_url.contains("https://") {
vec![
activity::Button::new(
"Download",
"https://github.com/music-assistant/music-assistant-desktop/releases/latest/",
"Download companion",
"https://music-assistant.io/companion-app/",
),
activity::Button::new("Preview song!", &current_song.preview_url),
activity::Button::new("Open in browser", &current_song.provider_url),
]
} else {
vec![activity::Button::new(
"Download",
"https://github.com/music-assistant/music-assistant-desktop/releases/latest/",
"Download companion",
"https://music-assistant.io/companion-app/",
)]
};

Expand Down

0 comments on commit 6dbe587

Please sign in to comment.