Pull media for Playnite from LANCommander server if it exists

media
Pat Hartl 2023-11-02 23:37:10 -05:00
parent 82886221fc
commit 739453c8bc
5 changed files with 43 additions and 0 deletions

View File

@ -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...");

View File

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

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace LANCommander.SDK.Enums
{
public enum MediaType
{
Icon,
Cover,
Background
}
}

View File

@ -16,6 +16,7 @@ namespace LANCommander.SDK.Models
public virtual Company Developer { get; set; }
public virtual IEnumerable<Archive> Archives { get; set; }
public virtual IEnumerable<Script> Scripts { get; set; }
public virtual IEnumerable<Media> Media { get; set; }
public virtual IEnumerable<Redistributable> Redistributables { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using LANCommander.SDK.Enums;
using System;
using System.Collections.Generic;
using System.Text;
namespace LANCommander.SDK.Models
{
public class Media : BaseModel
{
public Guid FileId { get; set; }
public MediaType Type { get; set; }
public string SourceUrl { get; set; }
public string MimeType { get; set; }
}
}