diff --git a/LANCommander.Playnite.Extension/LANCommanderClient.cs b/LANCommander.Playnite.Extension/LANCommanderClient.cs index b5ecce6..e2cdfd1 100644 --- a/LANCommander.Playnite.Extension/LANCommanderClient.cs +++ b/LANCommander.Playnite.Extension/LANCommanderClient.cs @@ -235,6 +235,11 @@ namespace LANCommander.PlaynitePlugin return response.Data; } + public string GetMediaUrl(Media media) + { + return (new Uri(Client.BaseUrl, $"/api/Media/{media.Id}/Download?fileId={media.FileId}").ToString()); + } + public string GetKey(Guid id) { Logger.Trace("Requesting key allocation..."); diff --git a/LANCommander.Playnite.Extension/LANCommanderLibraryPlugin.cs b/LANCommander.Playnite.Extension/LANCommanderLibraryPlugin.cs index d444245..a5cf79f 100644 --- a/LANCommander.Playnite.Extension/LANCommanderLibraryPlugin.cs +++ b/LANCommander.Playnite.Extension/LANCommanderLibraryPlugin.cs @@ -183,6 +183,15 @@ namespace LANCommander.PlaynitePlugin if (manifest.OnlineMultiplayer != null) metadata.Features.Add(new MetadataNameProperty($"Online Multiplayer {manifest.OnlineMultiplayer.GetPlayerCount()}".Trim())); + if (game.Media.Any(m => m.Type == SDK.Enums.MediaType.Icon)) + metadata.Icon = new MetadataFile(LANCommander.GetMediaUrl(game.Media.First(m => m.Type == SDK.Enums.MediaType.Icon))); + + if (game.Media.Any(m => m.Type == SDK.Enums.MediaType.Cover)) + metadata.CoverImage = new MetadataFile(LANCommander.GetMediaUrl(game.Media.First(m => m.Type == SDK.Enums.MediaType.Cover))); + + if (game.Media.Any(m => m.Type == SDK.Enums.MediaType.Background)) + metadata.BackgroundImage = new MetadataFile(LANCommander.GetMediaUrl(game.Media.First(m => m.Type == SDK.Enums.MediaType.Background))); + gameMetadata.Add(metadata); } catch (Exception ex) diff --git a/LANCommander.SDK/Enums/MediaType.cs b/LANCommander.SDK/Enums/MediaType.cs new file mode 100644 index 0000000..d5283ba --- /dev/null +++ b/LANCommander.SDK/Enums/MediaType.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace LANCommander.SDK.Enums +{ + public enum MediaType + { + Icon, + Cover, + Background + } +} diff --git a/LANCommander.SDK/Models/Game.cs b/LANCommander.SDK/Models/Game.cs index 39e102e..d13737b 100644 --- a/LANCommander.SDK/Models/Game.cs +++ b/LANCommander.SDK/Models/Game.cs @@ -16,6 +16,7 @@ namespace LANCommander.SDK.Models public virtual Company Developer { get; set; } public virtual IEnumerable Archives { get; set; } public virtual IEnumerable