album art url in SpotifyActivity model
Some checks failed
Publish JS SDK / docker (push) Failing after 17s
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 56s

This commit is contained in:
Braydon 2024-09-09 21:16:12 -04:00
parent e6809a958f
commit 40a2a5a9d7
2 changed files with 17 additions and 2 deletions

@ -191,6 +191,11 @@ public final class DiscordUser {
*/
@NonNull private final String album;
/**
* The URL to the art for the currently playing album.
*/
@NonNull private final String albumArtUrl;
/**
* The URL to the playing track.
*/
@ -224,6 +229,11 @@ public final class DiscordUser {
*/
@NonNull @SuppressWarnings("DataFlowIssue")
public static SpotifyActivity fromActivity(@NonNull RichPresence richPresence) {
// Obtain track URLs
String albumArtUrl = "https://i.scdn.co/image/" + richPresence.getLargeImage().getUrl().split(":")[1];
String trackUrl = "https://open.spotify.com/track/" + richPresence.getSyncId();
// Track progress
long started = Objects.requireNonNull(richPresence.getTimestamps()).getStart();
long ends = richPresence.getTimestamps().getEnd();
@ -231,8 +241,8 @@ public final class DiscordUser {
long trackProgress = Math.min(System.currentTimeMillis() - started, trackLength);
return new SpotifyActivity(
richPresence.getDetails(), richPresence.getState().replace(";", ","),
richPresence.getLargeImage().getText(), trackProgress, trackLength, started, ends
richPresence.getSyncId(), richPresence.getDetails(), richPresence.getState().replace(";", ","),
richPresence.getLargeImage().getText(), albumArtUrl, trackUrl, trackProgress, trackLength, started, ends
);
}
}

@ -146,6 +146,11 @@ export type SpotifyActivity = {
*/
album: string;
/**
* The URL to the art for the currently playing album.
*/
albumArtUrl: string;
/**
* The URL to the playing track.
*/