Clean up SpotifyGame PR
- Add a helper under CDN for cover art URLs It would be bad practice of us to leave CDN urls hardcoded in the deserializer, would be harder to change down the line should Spotify ever change their CDN. I'm not entirely supportive of leaving Spotify's CDN hardcoded in our lib either, but there's no better alternative. - Change SpotifyGame#Artists to an IEnumerable<string> Seems pretty common to prefer IEnumerables in place of Arrays.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
@@ -28,6 +28,9 @@ namespace Discord
|
||||
return $"{DiscordConfig.CDNUrl}app-assets/{appId}/{assetId}.{extension}?size={size}";
|
||||
}
|
||||
|
||||
public static string GetSpotifyAlbumArtUrl(string albumArtId)
|
||||
=> $"https://i.scdn.co/image/{albumArtId}";
|
||||
|
||||
private static string FormatToExtension(ImageFormat format, string imageId)
|
||||
{
|
||||
if (format == ImageFormat.Auto)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Discord
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class SpotifyGame : Game
|
||||
{
|
||||
public string[] Artists { get; internal set; }
|
||||
public IEnumerable<string> Artists { get; internal set; }
|
||||
public string AlbumArt { get; internal set; }
|
||||
public string AlbumTitle { get; internal set; }
|
||||
public string TrackTitle { get; internal set; }
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Discord.WebSocket
|
||||
TrackTitle = model.Details.GetValueOrDefault(),
|
||||
Artists = model.State.GetValueOrDefault()?.Split(';'),
|
||||
Duration = timestamps?.End - timestamps?.Start,
|
||||
AlbumArt = albumArtId != null ? $"https://i.scdn.co/image/{albumArtId}" : null,
|
||||
AlbumArt = albumArtId != null ? CDN.GetSpotifyAlbumArtUrl(albumArtId) : null,
|
||||
Type = ActivityType.Listening
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user