feat: added support for platform logos

This commit is contained in:
Michael Green
2023-04-09 23:45:48 +10:00
parent 913a7ad1e3
commit 36616caf7b
6 changed files with 62 additions and 14 deletions

View File

@@ -96,19 +96,7 @@ namespace gaseous_server.Classes.Metadata
// get platform logo
if (result.PlatformLogo != null)
{
var logo_results = await igdb.QueryAsync<PlatformLogo>(IGDBClient.Endpoints.PlatformLogos, query: "fields alpha_channel,animated,checksum,height,image_id,url,width; where id = " + result.PlatformLogo.Id + ";");
var logo_result = logo_results.First();
using (var client = new HttpClient())
{
using (var s = client.GetStreamAsync("https:" + logo_result.Url))
{
using (var fs = new FileStream(Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Platform(result), "platform_logo.jpg"), FileMode.OpenOrCreate))
{
s.Result.CopyTo(fs);
}
}
}
PlatformLogos.GetPlatformLogo((long)result.PlatformLogo.Id, Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Platform(result), "platform_logo.jpg"));
}
return result;