Browse Source

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.
pull/986/head
Christopher F 7 years ago
parent
commit
02c650773d
3 changed files with 6 additions and 3 deletions
  1. +4
    -1
      src/Discord.Net.Core/CDN.cs
  2. +1
    -1
      src/Discord.Net.Core/Entities/Activities/SpotifyGame.cs
  3. +1
    -1
      src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs

+ 4
- 1
src/Discord.Net.Core/CDN.cs View File

@@ -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)


+ 1
- 1
src/Discord.Net.Core/Entities/Activities/SpotifyGame.cs View File

@@ -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; }


+ 1
- 1
src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs View File

@@ -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
};
}


Loading…
Cancel
Save