feat: added support for platform logos
This commit is contained in:
@@ -94,7 +94,7 @@ namespace gaseous_server.Classes
|
||||
|
||||
//Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(discoveredSignature));
|
||||
|
||||
IGDB.Models.Platform determinedPlatform = Platforms.GetPlatform(discoveredSignature.Flags.IGDBPlatformId);
|
||||
IGDB.Models.Platform determinedPlatform = Metadata.Platforms.GetPlatform(discoveredSignature.Flags.IGDBPlatformId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
gaseous-server/Classes/Metadata/PlatformLogos.cs
Normal file
40
gaseous-server/Classes/Metadata/PlatformLogos.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using gaseous_tools;
|
||||
using IGDB;
|
||||
using IGDB.Models;
|
||||
using MySqlX.XDevAPI.Common;
|
||||
using static gaseous_tools.Config.ConfigFile;
|
||||
|
||||
namespace gaseous_server.Classes.Metadata
|
||||
{
|
||||
public class PlatformLogos
|
||||
{
|
||||
public PlatformLogos()
|
||||
{
|
||||
}
|
||||
|
||||
private static IGDBClient igdb = new IGDBClient(
|
||||
// Found in Twitch Developer portal for your app
|
||||
Config.IGDB.ClientId,
|
||||
Config.IGDB.Secret
|
||||
);
|
||||
|
||||
public async static void GetPlatformLogo(long Id, string LogoPath)
|
||||
{
|
||||
var logo_results = await igdb.QueryAsync<PlatformLogo>(IGDBClient.Endpoints.PlatformLogos, query: "fields alpha_channel,animated,checksum,height,image_id,url,width; where id = " + 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(LogoPath, FileMode.OpenOrCreate))
|
||||
{
|
||||
s.Result.CopyTo(fs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<None Remove="Classes\" />
|
||||
<None Remove="Classes\SignatureIngestors\" />
|
||||
<None Remove="Support\" />
|
||||
<None Remove="Classes\Metadata\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
@@ -31,6 +32,7 @@
|
||||
<Folder Include="Classes\SignatureIngestors\" />
|
||||
<Folder Include="Support\" />
|
||||
<Folder Include="wwwroot\" />
|
||||
<Folder Include="Classes\Metadata\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\gaseous-tools\gaseous-tools.csproj">
|
||||
|
||||
Reference in New Issue
Block a user