WIP
This commit is contained in:
@@ -345,7 +345,7 @@ namespace gaseous_server.Classes
|
|||||||
) && alwaysIncludeItem.PlatformId == platform.Id
|
) && alwaysIncludeItem.PlatformId == platform.Id
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MinimalGameItem AlwaysIncludeGame = new MinimalGameItem(Games.GetGame(Communications.MetadataSource, alwaysIncludeItem.GameId));
|
MinimalGameItem AlwaysIncludeGame = new MinimalGameItem(Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, alwaysIncludeItem.GameId));
|
||||||
CollectionContents.CollectionPlatformItem.CollectionGameItem gameItem = new CollectionContents.CollectionPlatformItem.CollectionGameItem(AlwaysIncludeGame);
|
CollectionContents.CollectionPlatformItem.CollectionGameItem gameItem = new CollectionContents.CollectionPlatformItem.CollectionGameItem(AlwaysIncludeGame);
|
||||||
gameItem.InclusionStatus = new CollectionItem.AlwaysIncludeItem();
|
gameItem.InclusionStatus = new CollectionItem.AlwaysIncludeItem();
|
||||||
gameItem.InclusionStatus.PlatformId = alwaysIncludeItem.PlatformId;
|
gameItem.InclusionStatus.PlatformId = alwaysIncludeItem.PlatformId;
|
||||||
|
@@ -114,7 +114,12 @@ namespace gaseous_server.Classes
|
|||||||
if (File.Exists(ConfigurationFilePath))
|
if (File.Exists(ConfigurationFilePath))
|
||||||
{
|
{
|
||||||
string configRaw = File.ReadAllText(ConfigurationFilePath);
|
string configRaw = File.ReadAllText(ConfigurationFilePath);
|
||||||
ConfigFile? _tempConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<ConfigFile>(configRaw);
|
Newtonsoft.Json.JsonSerializerSettings serializerSettings = new Newtonsoft.Json.JsonSerializerSettings
|
||||||
|
{
|
||||||
|
NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
|
||||||
|
MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore
|
||||||
|
};
|
||||||
|
ConfigFile? _tempConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<ConfigFile>(configRaw, serializerSettings);
|
||||||
if (_tempConfig != null)
|
if (_tempConfig != null)
|
||||||
{
|
{
|
||||||
_config = _tempConfig;
|
_config = _tempConfig;
|
||||||
@@ -130,7 +135,8 @@ namespace gaseous_server.Classes
|
|||||||
_config.DatabaseConfiguration.Password = (string)Common.GetEnvVar("dbpass", _config.DatabaseConfiguration.Password);
|
_config.DatabaseConfiguration.Password = (string)Common.GetEnvVar("dbpass", _config.DatabaseConfiguration.Password);
|
||||||
_config.DatabaseConfiguration.DatabaseName = (string)Common.GetEnvVar("dbname", _config.DatabaseConfiguration.DatabaseName);
|
_config.DatabaseConfiguration.DatabaseName = (string)Common.GetEnvVar("dbname", _config.DatabaseConfiguration.DatabaseName);
|
||||||
_config.DatabaseConfiguration.Port = int.Parse((string)Common.GetEnvVar("dbport", _config.DatabaseConfiguration.Port.ToString()));
|
_config.DatabaseConfiguration.Port = int.Parse((string)Common.GetEnvVar("dbport", _config.DatabaseConfiguration.Port.ToString()));
|
||||||
_config.MetadataConfiguration.MetadataSource = (HasheousClient.Models.MetadataModel.MetadataSources)Enum.Parse(typeof(HasheousClient.Models.MetadataModel.MetadataSources), (string)Common.GetEnvVar("metadatasource", _config.MetadataConfiguration.MetadataSource.ToString()));
|
_config.MetadataConfiguration.DefaultMetadataSource = (HasheousClient.Models.MetadataSources)Enum.Parse(typeof(HasheousClient.Models.MetadataSources), (string)Common.GetEnvVar("metadatasource", _config.MetadataConfiguration.DefaultMetadataSource.ToString()));
|
||||||
|
_config.MetadataConfiguration.MetadataUseHasheousProxy = bool.Parse((string)Common.GetEnvVar("metadatausehasheousproxy", _config.MetadataConfiguration.MetadataUseHasheousProxy.ToString()));
|
||||||
_config.MetadataConfiguration.SignatureSource = (HasheousClient.Models.MetadataModel.SignatureSources)Enum.Parse(typeof(HasheousClient.Models.MetadataModel.SignatureSources), (string)Common.GetEnvVar("signaturesource", _config.MetadataConfiguration.SignatureSource.ToString())); ;
|
_config.MetadataConfiguration.SignatureSource = (HasheousClient.Models.MetadataModel.SignatureSources)Enum.Parse(typeof(HasheousClient.Models.MetadataModel.SignatureSources), (string)Common.GetEnvVar("signaturesource", _config.MetadataConfiguration.SignatureSource.ToString())); ;
|
||||||
_config.MetadataConfiguration.MaxLibraryScanWorkers = int.Parse((string)Common.GetEnvVar("maxlibraryscanworkers", _config.MetadataConfiguration.MaxLibraryScanWorkers.ToString()));
|
_config.MetadataConfiguration.MaxLibraryScanWorkers = int.Parse((string)Common.GetEnvVar("maxlibraryscanworkers", _config.MetadataConfiguration.MaxLibraryScanWorkers.ToString()));
|
||||||
_config.MetadataConfiguration.HasheousHost = (string)Common.GetEnvVar("hasheoushost", _config.MetadataConfiguration.HasheousHost);
|
_config.MetadataConfiguration.HasheousHost = (string)Common.GetEnvVar("hasheoushost", _config.MetadataConfiguration.HasheousHost);
|
||||||
@@ -684,17 +690,32 @@ namespace gaseous_server.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HasheousClient.Models.MetadataModel.MetadataSources _MetadataSource
|
private static HasheousClient.Models.MetadataSources _MetadataSource
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("metadatasource")))
|
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("metadatasource")))
|
||||||
{
|
{
|
||||||
return (HasheousClient.Models.MetadataModel.MetadataSources)Enum.Parse(typeof(HasheousClient.Models.MetadataModel.MetadataSources), Environment.GetEnvironmentVariable("metadatasource"));
|
return (HasheousClient.Models.MetadataSources)Enum.Parse(typeof(HasheousClient.Models.MetadataSources), Environment.GetEnvironmentVariable("metadatasource"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return HasheousClient.Models.MetadataModel.MetadataSources.IGDB;
|
return HasheousClient.Models.MetadataSources.IGDB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool _MetadataUseHasheousProxy
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("metadatausehasheousproxy")))
|
||||||
|
{
|
||||||
|
return bool.Parse(Environment.GetEnvironmentVariable("metadatausehasheousproxy"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -748,7 +769,9 @@ namespace gaseous_server.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HasheousClient.Models.MetadataModel.MetadataSources MetadataSource = _MetadataSource;
|
public HasheousClient.Models.MetadataSources DefaultMetadataSource = _MetadataSource;
|
||||||
|
|
||||||
|
public bool MetadataUseHasheousProxy = _MetadataUseHasheousProxy;
|
||||||
|
|
||||||
public HasheousClient.Models.MetadataModel.SignatureSources SignatureSource = _SignatureSource;
|
public HasheousClient.Models.MetadataModel.SignatureSources SignatureSource = _SignatureSource;
|
||||||
|
|
||||||
|
@@ -394,7 +394,7 @@ namespace gaseous_server.Classes
|
|||||||
);
|
);
|
||||||
|
|
||||||
HasheousClient.Models.Metadata.IGDB.Platform platform = Platforms.GetPlatform((long)row["PlatformId"]);
|
HasheousClient.Models.Metadata.IGDB.Platform platform = Platforms.GetPlatform((long)row["PlatformId"]);
|
||||||
Game game = Games.GetGame(Communications.MetadataSource, (long)row["GameId"]);
|
Game game = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, (long)row["GameId"]);
|
||||||
|
|
||||||
ImportGame.StoreROM(library, hash, game, platform, signature, (string)row["Path"], (long)row["Id"]);
|
ImportGame.StoreROM(library, hash, game, platform, signature, (string)row["Path"], (long)row["Id"]);
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ using System.IO.Compression;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using gaseous_server.Classes.Metadata;
|
using gaseous_server.Classes.Metadata;
|
||||||
using HasheousClient.Models;
|
using HasheousClient.Models;
|
||||||
|
using HasheousClient.Models.Metadata.IGDB;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using NuGet.Common;
|
using NuGet.Common;
|
||||||
using SevenZip;
|
using SevenZip;
|
||||||
@@ -185,6 +186,22 @@ namespace gaseous_server.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get discovered platform
|
||||||
|
Platform? determinedPlatform = null;
|
||||||
|
if (library.DefaultPlatformId == null || library.DefaultPlatformId == 0)
|
||||||
|
{
|
||||||
|
determinedPlatform = Metadata.Platforms.GetPlatform((long)discoveredSignature.Flags.PlatformId);
|
||||||
|
if (determinedPlatform == null)
|
||||||
|
{
|
||||||
|
determinedPlatform = new Platform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
determinedPlatform = Metadata.Platforms.GetPlatform((long)library.DefaultPlatformId);
|
||||||
|
discoveredSignature.MetadataSources.AddPlatform((long)determinedPlatform.Id, determinedPlatform.Name, MetadataSources.None);
|
||||||
|
}
|
||||||
|
|
||||||
return discoveredSignature;
|
return discoveredSignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +254,7 @@ namespace gaseous_server.Classes
|
|||||||
gaseous_server.Models.PlatformMapping.GetIGDBPlatformMapping(ref discoveredSignature, ImageExtension, false);
|
gaseous_server.Models.PlatformMapping.GetIGDBPlatformMapping(ref discoveredSignature, ImageExtension, false);
|
||||||
|
|
||||||
Logging.Log(Logging.LogType.Information, "Import Game", " Determined import file as: " + discoveredSignature.Game.Name + " (" + discoveredSignature.Game.Year + ") " + discoveredSignature.Game.System);
|
Logging.Log(Logging.LogType.Information, "Import Game", " Determined import file as: " + discoveredSignature.Game.Name + " (" + discoveredSignature.Game.Year + ") " + discoveredSignature.Game.System);
|
||||||
Logging.Log(Logging.LogType.Information, "Import Game", " Platform determined to be: " + discoveredSignature.Flags.IGDBPlatformName + " (" + discoveredSignature.Flags.IGDBPlatformId + ")");
|
Logging.Log(Logging.LogType.Information, "Import Game", " Platform determined to be: " + discoveredSignature.Flags.PlatformName + " (" + discoveredSignature.Flags.PlatformId + ")");
|
||||||
|
|
||||||
return discoveredSignature;
|
return discoveredSignature;
|
||||||
}
|
}
|
||||||
@@ -319,12 +336,8 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
if (metadataResult.Id.Length > 0)
|
if (metadataResult.Id.Length > 0)
|
||||||
{
|
{
|
||||||
switch (metadataResult.Source)
|
Platform hasheousPlatform = Platforms.GetPlatform(metadataResult.Id);
|
||||||
{
|
signature.MetadataSources.AddPlatform((long)hasheousPlatform.Id, hasheousPlatform.Name, metadataResult.Source);
|
||||||
case HasheousClient.Models.MetadataSources.IGDB:
|
|
||||||
signature.Flags.IGDBPlatformId = (long)Platforms.GetPlatform(metadataResult.Id).Id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,12 +352,8 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
if (metadataResult.Id.Length > 0)
|
if (metadataResult.Id.Length > 0)
|
||||||
{
|
{
|
||||||
switch (metadataResult.Source)
|
Game hasheousGame = Games.GetGame(MetadataSources.IGDB, metadataResult.Id);
|
||||||
{
|
signature.MetadataSources.AddGame((long)hasheousGame.Id, hasheousGame.Name, metadataResult.Source);
|
||||||
case HasheousClient.Models.MetadataSources.IGDB:
|
|
||||||
signature.Flags.IGDBGameId = (long)Games.GetGame(Communications.MetadataSource, metadataResult.Id).Id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -159,30 +159,15 @@ namespace gaseous_server.Classes
|
|||||||
FileSignature fileSignature = new FileSignature();
|
FileSignature fileSignature = new FileSignature();
|
||||||
gaseous_server.Models.Signatures_Games discoveredSignature = fileSignature.GetFileSignature(GameLibrary.GetDefaultLibrary, Hash, fi, FilePath);
|
gaseous_server.Models.Signatures_Games discoveredSignature = fileSignature.GetFileSignature(GameLibrary.GetDefaultLibrary, Hash, fi, FilePath);
|
||||||
|
|
||||||
// get discovered platform
|
|
||||||
Platform? determinedPlatform = null;
|
|
||||||
if (OverridePlatform == null)
|
|
||||||
{
|
|
||||||
determinedPlatform = Metadata.Platforms.GetPlatform(discoveredSignature.Flags.IGDBPlatformId);
|
|
||||||
if (determinedPlatform == null)
|
|
||||||
{
|
|
||||||
determinedPlatform = new Platform();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
determinedPlatform = OverridePlatform;
|
|
||||||
discoveredSignature.Flags.IGDBPlatformId = (long)determinedPlatform.Id;
|
|
||||||
discoveredSignature.Flags.IGDBPlatformName = determinedPlatform.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add to database
|
// add to database
|
||||||
long RomId = StoreGame(GameLibrary.GetDefaultLibrary, Hash, discoveredSignature, determinedPlatform, FilePath, 0, false);
|
Platform? determinedPlatform = Metadata.Platforms.GetPlatform((long)discoveredSignature.Flags.PlatformId);
|
||||||
|
Models.Game? determinedGame = Metadata.Games.GetGame(discoveredSignature.Flags.GameMetadataSource, discoveredSignature.Flags.GameId);
|
||||||
|
long RomId = StoreGame(GameLibrary.GetDefaultLibrary, Hash, discoveredSignature, determinedPlatform, FilePath, 0, true);
|
||||||
|
|
||||||
// build return value
|
// build return value
|
||||||
GameFileInfo.Add("romid", RomId);
|
GameFileInfo.Add("romid", RomId);
|
||||||
GameFileInfo.Add("platform", determinedPlatform);
|
GameFileInfo.Add("platform", determinedPlatform);
|
||||||
GameFileInfo.Add("game", discoveredSignature.Game.Name);
|
GameFileInfo.Add("game", determinedGame);
|
||||||
GameFileInfo.Add("signature", discoveredSignature);
|
GameFileInfo.Add("signature", discoveredSignature);
|
||||||
GameFileInfo.Add("status", "imported");
|
GameFileInfo.Add("status", "imported");
|
||||||
}
|
}
|
||||||
@@ -217,34 +202,45 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||||
|
|
||||||
// add the metadata map
|
// add/get the metadata map
|
||||||
// check if the map exists already
|
MetadataMap? map = MetadataManagement.NewMetadataMap((long)platform.Id, signature.Game.Name);
|
||||||
long mapId = 0;
|
|
||||||
sql = "SELECT ParentMapId FROM MetadataMapBridge WHERE SignatureGameName=@gamename AND SignaturePlatformId=@platformid;";
|
|
||||||
dbDict = new Dictionary<string, object>(){
|
|
||||||
{ "gamename", signature.Game.Name },
|
|
||||||
{ "platformid", platform.Id }
|
|
||||||
};
|
|
||||||
DataTable mapDT = db.ExecuteCMD(sql, dbDict);
|
|
||||||
|
|
||||||
if (mapDT.Rows.Count > 0)
|
// populate map with the sources from the signature if they don't already exist
|
||||||
|
bool reloadMap = false;
|
||||||
|
foreach (MetadataSources source in Enum.GetValues(typeof(MetadataSources)))
|
||||||
{
|
{
|
||||||
mapId = (long)mapDT.Rows[0]["ParentMapId"];
|
if (source != MetadataSources.None)
|
||||||
|
{
|
||||||
|
// check the signature for the source, and if it exists, add it to the map if it's not already there
|
||||||
|
foreach (Signatures_Games.SourceValues.SourceValueItem signatureSource in signature.MetadataSources.Games)
|
||||||
|
{
|
||||||
|
// check if the metadata map contains the source
|
||||||
|
bool sourceExists = false;
|
||||||
|
foreach (MetadataMap.MetadataMapItem mapSource in map.MetadataMapItems)
|
||||||
|
{
|
||||||
|
if (mapSource.SourceType == source)
|
||||||
|
{
|
||||||
|
sourceExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sourceExists == false)
|
||||||
|
{
|
||||||
|
// add the source to the map
|
||||||
|
bool preferred = false;
|
||||||
|
if (source == Config.MetadataConfiguration.DefaultMetadataSource)
|
||||||
|
{
|
||||||
|
preferred = true;
|
||||||
|
}
|
||||||
|
MetadataManagement.AddMetadataMapItem((long)map.Id, source, signatureSource.Id, preferred);
|
||||||
|
reloadMap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (reloadMap == true)
|
||||||
{
|
{
|
||||||
sql = "INSERT INTO MetadataMapBridge (ParentMapId, SignatureGameName, SignaturePlatformId, MetadataSourceType, MetadataSourceId, Preferred, ProcessedAtImport) VALUES (@parentmapid, @gamename, @platformid, @metadatasourcetype, @metadatasourceid, @preferred, @processedatimport); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
map = MetadataManagement.GetMetadataMap((long)map.Id);
|
||||||
dbDict = new Dictionary<string, object>(){
|
|
||||||
{ "parentmapid", 0 },
|
|
||||||
{ "gamename", signature.Game.Name },
|
|
||||||
{ "platformid", platform.Id },
|
|
||||||
{ "metadatasourcetype", MetadataModel.MetadataSources.None },
|
|
||||||
{ "metadatasourceid", 0 }, // set to zero as an initial value - another process will update this later
|
|
||||||
{ "preferred", 1 },
|
|
||||||
{ "processedatimport", 0 }
|
|
||||||
};
|
|
||||||
DataTable mapInsert = db.ExecuteCMD(sql, dbDict);
|
|
||||||
mapId = (long)mapInsert.Rows[0][0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add or update the rom
|
// add or update the rom
|
||||||
@@ -271,7 +267,7 @@ namespace gaseous_server.Classes
|
|||||||
dbDict.Add("metadataversion", 2);
|
dbDict.Add("metadataversion", 2);
|
||||||
dbDict.Add("libraryid", library.Id);
|
dbDict.Add("libraryid", library.Id);
|
||||||
dbDict.Add("romdataversion", 2);
|
dbDict.Add("romdataversion", 2);
|
||||||
dbDict.Add("metadatamapid", mapId);
|
dbDict.Add("metadatamapid", map.Id);
|
||||||
|
|
||||||
if (signature.Rom.Attributes != null)
|
if (signature.Rom.Attributes != null)
|
||||||
{
|
{
|
||||||
@@ -308,7 +304,7 @@ namespace gaseous_server.Classes
|
|||||||
// move to destination
|
// move to destination
|
||||||
if (library.IsDefaultLibrary == true)
|
if (library.IsDefaultLibrary == true)
|
||||||
{
|
{
|
||||||
//MoveGameFile(romId, SourceIsExternal);
|
MoveGameFile(romId, SourceIsExternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return romId;
|
return romId;
|
||||||
@@ -318,12 +314,12 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
if (Signature.Flags != null)
|
if (Signature.Flags != null)
|
||||||
{
|
{
|
||||||
if (Signature.Flags.IGDBGameId != null && Signature.Flags.IGDBGameId != 0)
|
if (Signature.Flags.GameId != null && Signature.Flags.GameId != 0)
|
||||||
{
|
{
|
||||||
// game was determined elsewhere - probably a Hasheous server
|
// game was determined elsewhere - probably a Hasheous server
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Games.GetGame(Communications.MetadataSource, Signature.Flags.IGDBGameId);
|
return Games.GetGame(MetadataSources.IGDB, Signature.Flags.GameId);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -354,7 +350,7 @@ namespace gaseous_server.Classes
|
|||||||
if (games.Length == 1)
|
if (games.Length == 1)
|
||||||
{
|
{
|
||||||
// exact match!
|
// exact match!
|
||||||
determinedGame = Metadata.Games.GetGame(Communications.MetadataSource, (long)games[0].Id);
|
determinedGame = Metadata.Games.GetGame(MetadataSources.IGDB, (long)games[0].Id);
|
||||||
Logging.Log(Logging.LogType.Information, "Import Game", " IGDB game: " + determinedGame.Name);
|
Logging.Log(Logging.LogType.Information, "Import Game", " IGDB game: " + determinedGame.Name);
|
||||||
GameFound = true;
|
GameFound = true;
|
||||||
break;
|
break;
|
||||||
@@ -369,7 +365,7 @@ namespace gaseous_server.Classes
|
|||||||
if (game.Name == SearchCandidate)
|
if (game.Name == SearchCandidate)
|
||||||
{
|
{
|
||||||
// found game title matches the search candidate
|
// found game title matches the search candidate
|
||||||
determinedGame = Metadata.Games.GetGame(Communications.MetadataSource, (long)games[0].Id);
|
determinedGame = Metadata.Games.GetGame(MetadataSources.IGDB, (long)games[0].Id);
|
||||||
Logging.Log(Logging.LogType.Information, "Import Game", "Found exact match!");
|
Logging.Log(Logging.LogType.Information, "Import Game", "Found exact match!");
|
||||||
GameFound = true;
|
GameFound = true;
|
||||||
break;
|
break;
|
||||||
@@ -551,8 +547,8 @@ namespace gaseous_server.Classes
|
|||||||
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
|
Classes.Roms.GameRomItem rom = Classes.Roms.GetRom(RomId);
|
||||||
|
|
||||||
// get metadata
|
// get metadata
|
||||||
Platform platform = gaseous_server.Classes.Metadata.Platforms.GetPlatform(rom.PlatformId);
|
Platform? platform = gaseous_server.Classes.Metadata.Platforms.GetPlatform(rom.PlatformId);
|
||||||
gaseous_server.Models.Game game = gaseous_server.Classes.Metadata.Games.GetGame(Communications.MetadataSource, rom.GameId);
|
gaseous_server.Models.Game? game = gaseous_server.Classes.Metadata.Games.GetGame(Config.MetadataConfiguration.DefaultMetadataSource, rom.GameId);
|
||||||
|
|
||||||
// build path
|
// build path
|
||||||
string platformSlug = "Unknown Platform";
|
string platformSlug = "Unknown Platform";
|
||||||
@@ -866,7 +862,7 @@ namespace gaseous_server.Classes
|
|||||||
long PlatformId;
|
long PlatformId;
|
||||||
Platform determinedPlatform;
|
Platform determinedPlatform;
|
||||||
|
|
||||||
if (sig.Flags.IGDBPlatformId == null || sig.Flags.IGDBPlatformId == 0)
|
if (sig.Flags.PlatformId == null || sig.Flags.PlatformId == 0)
|
||||||
{
|
{
|
||||||
// no platform discovered in the signature
|
// no platform discovered in the signature
|
||||||
PlatformId = library.DefaultPlatformId;
|
PlatformId = library.DefaultPlatformId;
|
||||||
@@ -874,7 +870,7 @@ namespace gaseous_server.Classes
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use the platform discovered in the signature
|
// use the platform discovered in the signature
|
||||||
PlatformId = sig.Flags.IGDBPlatformId;
|
PlatformId = (long)sig.Flags.PlatformId;
|
||||||
}
|
}
|
||||||
determinedPlatform = Platforms.GetPlatform(PlatformId);
|
determinedPlatform = Platforms.GetPlatform(PlatformId);
|
||||||
|
|
||||||
@@ -992,7 +988,7 @@ namespace gaseous_server.Classes
|
|||||||
long PlatformId;
|
long PlatformId;
|
||||||
Platform determinedPlatform;
|
Platform determinedPlatform;
|
||||||
|
|
||||||
if (sig.Flags.IGDBPlatformId == null || sig.Flags.IGDBPlatformId == 0)
|
if (sig.Flags.PlatformId == null || sig.Flags.PlatformId == 0)
|
||||||
{
|
{
|
||||||
// no platform discovered in the signature
|
// no platform discovered in the signature
|
||||||
PlatformId = library.DefaultPlatformId;
|
PlatformId = library.DefaultPlatformId;
|
||||||
@@ -1000,7 +996,7 @@ namespace gaseous_server.Classes
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use the platform discovered in the signature
|
// use the platform discovered in the signature
|
||||||
PlatformId = sig.Flags.IGDBPlatformId;
|
PlatformId = (long)sig.Flags.PlatformId;
|
||||||
}
|
}
|
||||||
determinedPlatform = Platforms.GetPlatform(PlatformId);
|
determinedPlatform = Platforms.GetPlatform(PlatformId);
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Storage.CacheStatus? cacheStatus = new Storage.CacheStatus();
|
Storage.CacheStatus? cacheStatus = new Storage.CacheStatus();
|
||||||
cacheStatus = Storage.GetCacheStatus(Communications.MetadataSource, "AgeGroup", (long)game.Id);
|
cacheStatus = Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.IGDB, "AgeGroup", (long)game.Id);
|
||||||
|
|
||||||
AgeGroup? RetVal = new AgeGroup();
|
AgeGroup? RetVal = new AgeGroup();
|
||||||
|
|
||||||
@@ -31,16 +31,16 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
case Storage.CacheStatus.NotPresent:
|
case Storage.CacheStatus.NotPresent:
|
||||||
RetVal = _GetAgeGroup(game);
|
RetVal = _GetAgeGroup(game);
|
||||||
Storage.NewCacheValue(Communications.MetadataSource, RetVal, false);
|
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.IGDB, RetVal, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Storage.CacheStatus.Expired:
|
case Storage.CacheStatus.Expired:
|
||||||
RetVal = _GetAgeGroup(game);
|
RetVal = _GetAgeGroup(game);
|
||||||
Storage.NewCacheValue(Communications.MetadataSource, RetVal, true);
|
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.IGDB, RetVal, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Storage.CacheStatus.Current:
|
case Storage.CacheStatus.Current:
|
||||||
RetVal = Storage.GetCacheValue<AgeGroup>(Communications.MetadataSource, RetVal, "Id", game.Id);
|
RetVal = Storage.GetCacheValue<AgeGroup>(HasheousClient.Models.MetadataSources.IGDB, RetVal, "Id", game.Id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@@ -15,7 +15,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AgeRating? GetAgeRating(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static AgeRating? GetAgeRating(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameAgeRating GetConsolidatedAgeRating(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long RatingId)
|
public static GameAgeRating GetConsolidatedAgeRating(HasheousClient.Models.MetadataSources SourceType, long RatingId)
|
||||||
{
|
{
|
||||||
GameAgeRating gameAgeRating = new GameAgeRating();
|
GameAgeRating gameAgeRating = new GameAgeRating();
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AgeRatingContentDescription? GetAgeRatingContentDescriptions(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static AgeRatingContentDescription? GetAgeRatingContentDescriptions(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlternativeName? GetAlternativeNames(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static AlternativeName? GetAlternativeNames(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Artwork? GetArtwork(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Artwork? GetArtwork(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection? GetCollections(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Collection? GetCollections(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -45,7 +45,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configure metadata API communications
|
/// Configure metadata API communications
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static HasheousClient.Models.MetadataModel.MetadataSources MetadataSource
|
public static HasheousClient.Models.MetadataSources MetadataSource
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -57,25 +57,27 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.IGDB:
|
case HasheousClient.Models.MetadataSources.IGDB:
|
||||||
// set rate limiter avoidance values
|
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
|
||||||
RateLimitAvoidanceWait = 1500;
|
{
|
||||||
RateLimitAvoidanceThreshold = 3;
|
// set rate limiter avoidance values
|
||||||
RateLimitAvoidancePeriod = 1;
|
RateLimitAvoidanceWait = 1500;
|
||||||
|
RateLimitAvoidanceThreshold = 3;
|
||||||
|
RateLimitAvoidancePeriod = 1;
|
||||||
|
|
||||||
// set rate limiter recovery values
|
// set rate limiter recovery values
|
||||||
RateLimitRecoveryWaitTime = 10000;
|
RateLimitRecoveryWaitTime = 10000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// set rate limiter avoidance values
|
||||||
|
RateLimitAvoidanceWait = 1500;
|
||||||
|
RateLimitAvoidanceThreshold = 6;
|
||||||
|
RateLimitAvoidancePeriod = 1;
|
||||||
|
|
||||||
break;
|
// set rate limiter recovery values
|
||||||
|
RateLimitRecoveryWaitTime = 10000;
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.Hasheous:
|
}
|
||||||
// set rate limiter avoidance values
|
|
||||||
RateLimitAvoidanceWait = 1500;
|
|
||||||
RateLimitAvoidanceThreshold = 6;
|
|
||||||
RateLimitAvoidancePeriod = 1;
|
|
||||||
|
|
||||||
// set rate limiter recovery values
|
|
||||||
RateLimitRecoveryWaitTime = 10000;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -85,7 +87,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static HasheousClient.Models.MetadataModel.MetadataSources _MetadataSource = HasheousClient.Models.MetadataModel.MetadataSources.None;
|
private static HasheousClient.Models.MetadataSources _MetadataSource = HasheousClient.Models.MetadataSources.None;
|
||||||
|
|
||||||
// rate limit avoidance - what can we do to ensure that rate limiting is avoided?
|
// rate limit avoidance - what can we do to ensure that rate limiting is avoided?
|
||||||
// these values affect all communications
|
// these values affect all communications
|
||||||
@@ -245,40 +247,44 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// The object requested
|
/// The object requested
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<T[]?> APIComm<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, MetadataEndpoint Endpoint, string Slug)
|
public async Task<T[]?> APIComm<T>(HasheousClient.Models.MetadataSources SourceType, MetadataEndpoint Endpoint, string Slug)
|
||||||
{
|
{
|
||||||
switch (SourceType)
|
switch (SourceType)
|
||||||
{
|
{
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.None:
|
case HasheousClient.Models.MetadataSources.None:
|
||||||
return null;
|
return null;
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.IGDB:
|
case HasheousClient.Models.MetadataSources.IGDB:
|
||||||
string fieldList = "";
|
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
|
||||||
string query = "where slug = \"" + Slug + "\"";
|
|
||||||
string EndpointString = "";
|
|
||||||
|
|
||||||
switch (Endpoint)
|
|
||||||
{
|
{
|
||||||
case MetadataEndpoint.Platform:
|
string fieldList = "";
|
||||||
fieldList = Platforms.fieldList;
|
string query = "where slug = \"" + Slug + "\"";
|
||||||
EndpointString = IGDBClient.Endpoints.Platforms;
|
string EndpointString = "";
|
||||||
break;
|
|
||||||
|
|
||||||
case MetadataEndpoint.Game:
|
switch (Endpoint)
|
||||||
fieldList = Games.fieldList;
|
{
|
||||||
EndpointString = IGDBClient.Endpoints.Games;
|
case MetadataEndpoint.Platform:
|
||||||
break;
|
fieldList = Platforms.fieldList;
|
||||||
|
EndpointString = IGDBClient.Endpoints.Platforms;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
case MetadataEndpoint.Game:
|
||||||
throw new Exception("Endpoint must be either Platform or Game");
|
fieldList = Games.fieldList;
|
||||||
|
EndpointString = IGDBClient.Endpoints.Games;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Exception("Endpoint must be either Platform or Game");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return await IGDBAPI<T>(EndpointString, fieldList, query);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConfigureHasheousClient(ref hasheous);
|
||||||
|
|
||||||
return await IGDBAPI<T>(EndpointString, fieldList, query);
|
return await HasheousAPI<T>(Endpoint.ToString(), "slug", Slug);
|
||||||
|
}
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.Hasheous:
|
|
||||||
ConfigureHasheousClient(ref hasheous);
|
|
||||||
|
|
||||||
return await HasheousAPI<T>(Endpoint.ToString(), "slug", Slug);
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@@ -323,145 +329,149 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// The object requested
|
/// The object requested
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<T[]> APIComm<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, MetadataEndpoint Endpoint, long Id)
|
public async Task<T[]> APIComm<T>(HasheousClient.Models.MetadataSources SourceType, MetadataEndpoint Endpoint, long Id)
|
||||||
{
|
{
|
||||||
switch (SourceType)
|
switch (SourceType)
|
||||||
{
|
{
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.None:
|
case HasheousClient.Models.MetadataSources.None:
|
||||||
return null;
|
return null;
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.IGDB:
|
case HasheousClient.Models.MetadataSources.IGDB:
|
||||||
string fieldList = "";
|
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
|
||||||
string query = "where id = " + Id;
|
|
||||||
string EndpointString = "";
|
|
||||||
|
|
||||||
switch (Endpoint)
|
|
||||||
{
|
{
|
||||||
case MetadataEndpoint.AgeRating:
|
string fieldList = "";
|
||||||
fieldList = AgeRatings.fieldList;
|
string query = "where id = " + Id;
|
||||||
EndpointString = IGDBClient.Endpoints.AgeRating;
|
string EndpointString = "";
|
||||||
break;
|
|
||||||
|
|
||||||
case MetadataEndpoint.AgeRatingContentDescription:
|
switch (Endpoint)
|
||||||
fieldList = AgeRatingContentDescriptions.fieldList;
|
{
|
||||||
EndpointString = IGDBClient.Endpoints.AgeRatingContentDescriptions;
|
case MetadataEndpoint.AgeRating:
|
||||||
break;
|
fieldList = AgeRatings.fieldList;
|
||||||
|
EndpointString = IGDBClient.Endpoints.AgeRating;
|
||||||
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.AlternativeName:
|
case MetadataEndpoint.AgeRatingContentDescription:
|
||||||
fieldList = AlternativeNames.fieldList;
|
fieldList = AgeRatingContentDescriptions.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.AlternativeNames;
|
EndpointString = IGDBClient.Endpoints.AgeRatingContentDescriptions;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Artwork:
|
case MetadataEndpoint.AlternativeName:
|
||||||
fieldList = Artworks.fieldList;
|
fieldList = AlternativeNames.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Artworks;
|
EndpointString = IGDBClient.Endpoints.AlternativeNames;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Collection:
|
case MetadataEndpoint.Artwork:
|
||||||
fieldList = Collections.fieldList;
|
fieldList = Artworks.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Collections;
|
EndpointString = IGDBClient.Endpoints.Artworks;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Company:
|
case MetadataEndpoint.Collection:
|
||||||
fieldList = Companies.fieldList;
|
fieldList = Collections.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Companies;
|
EndpointString = IGDBClient.Endpoints.Collections;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.CompanyLogo:
|
case MetadataEndpoint.Company:
|
||||||
fieldList = CompanyLogos.fieldList;
|
fieldList = Companies.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.CompanyLogos;
|
EndpointString = IGDBClient.Endpoints.Companies;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Cover:
|
case MetadataEndpoint.CompanyLogo:
|
||||||
fieldList = Covers.fieldList;
|
fieldList = CompanyLogos.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Covers;
|
EndpointString = IGDBClient.Endpoints.CompanyLogos;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.ExternalGame:
|
case MetadataEndpoint.Cover:
|
||||||
fieldList = ExternalGames.fieldList;
|
fieldList = Covers.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.ExternalGames;
|
EndpointString = IGDBClient.Endpoints.Covers;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Franchise:
|
case MetadataEndpoint.ExternalGame:
|
||||||
fieldList = Franchises.fieldList;
|
fieldList = ExternalGames.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Franchies;
|
EndpointString = IGDBClient.Endpoints.ExternalGames;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.GameMode:
|
case MetadataEndpoint.Franchise:
|
||||||
fieldList = GameModes.fieldList;
|
fieldList = Franchises.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.GameModes;
|
EndpointString = IGDBClient.Endpoints.Franchies;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Game:
|
case MetadataEndpoint.GameMode:
|
||||||
fieldList = Games.fieldList;
|
fieldList = GameModes.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Games;
|
EndpointString = IGDBClient.Endpoints.GameModes;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.GameVideo:
|
case MetadataEndpoint.Game:
|
||||||
fieldList = GamesVideos.fieldList;
|
fieldList = Games.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.GameVideos;
|
EndpointString = IGDBClient.Endpoints.Games;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Genre:
|
case MetadataEndpoint.GameVideo:
|
||||||
fieldList = Genres.fieldList;
|
fieldList = GamesVideos.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Genres;
|
EndpointString = IGDBClient.Endpoints.GameVideos;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.InvolvedCompany:
|
case MetadataEndpoint.Genre:
|
||||||
fieldList = InvolvedCompanies.fieldList;
|
fieldList = Genres.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.InvolvedCompanies;
|
EndpointString = IGDBClient.Endpoints.Genres;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.MultiplayerMode:
|
case MetadataEndpoint.InvolvedCompany:
|
||||||
fieldList = MultiplayerModes.fieldList;
|
fieldList = InvolvedCompanies.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.MultiplayerModes;
|
EndpointString = IGDBClient.Endpoints.InvolvedCompanies;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.PlatformLogo:
|
case MetadataEndpoint.MultiplayerMode:
|
||||||
fieldList = PlatformLogos.fieldList;
|
fieldList = MultiplayerModes.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.PlatformLogos;
|
EndpointString = IGDBClient.Endpoints.MultiplayerModes;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Platform:
|
case MetadataEndpoint.PlatformLogo:
|
||||||
fieldList = Platforms.fieldList;
|
fieldList = PlatformLogos.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Platforms;
|
EndpointString = IGDBClient.Endpoints.PlatformLogos;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.PlatformVersion:
|
case MetadataEndpoint.Platform:
|
||||||
fieldList = PlatformVersions.fieldList;
|
fieldList = Platforms.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.PlatformVersions;
|
EndpointString = IGDBClient.Endpoints.Platforms;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.PlayerPerspective:
|
case MetadataEndpoint.PlatformVersion:
|
||||||
fieldList = PlayerPerspectives.fieldList;
|
fieldList = PlatformVersions.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.PlayerPerspectives;
|
EndpointString = IGDBClient.Endpoints.PlatformVersions;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.ReleaseDate:
|
case MetadataEndpoint.PlayerPerspective:
|
||||||
fieldList = ReleaseDates.fieldList;
|
fieldList = PlayerPerspectives.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.ReleaseDates;
|
EndpointString = IGDBClient.Endpoints.PlayerPerspectives;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Screenshot:
|
case MetadataEndpoint.ReleaseDate:
|
||||||
fieldList = Screenshots.fieldList;
|
fieldList = ReleaseDates.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Screenshots;
|
EndpointString = IGDBClient.Endpoints.ReleaseDates;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MetadataEndpoint.Theme:
|
case MetadataEndpoint.Screenshot:
|
||||||
fieldList = Themes.fieldList;
|
fieldList = Screenshots.fieldList;
|
||||||
EndpointString = IGDBClient.Endpoints.Themes;
|
EndpointString = IGDBClient.Endpoints.Screenshots;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case MetadataEndpoint.Theme:
|
||||||
throw new Exception("Endpoint must be either Platform or Game");
|
fieldList = Themes.fieldList;
|
||||||
|
EndpointString = IGDBClient.Endpoints.Themes;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Exception("Endpoint must be either Platform or Game");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return await IGDBAPI<T>(EndpointString, fieldList, query);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConfigureHasheousClient(ref hasheous);
|
||||||
|
|
||||||
return await IGDBAPI<T>(EndpointString, fieldList, query);
|
return await HasheousAPI<T>(Endpoint.ToString(), "id", Id.ToString());
|
||||||
|
}
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.Hasheous:
|
|
||||||
ConfigureHasheousClient(ref hasheous);
|
|
||||||
|
|
||||||
return await HasheousAPI<T>(Endpoint.ToString(), "id", Id.ToString());
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -514,12 +524,17 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
switch (_MetadataSource)
|
switch (_MetadataSource)
|
||||||
{
|
{
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.None:
|
case HasheousClient.Models.MetadataSources.None:
|
||||||
return null;
|
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.IGDB:
|
|
||||||
return await IGDBAPI<T>(Endpoint, Fields, Query);
|
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.Hasheous:
|
|
||||||
return null;
|
return null;
|
||||||
|
case HasheousClient.Models.MetadataSources.IGDB:
|
||||||
|
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
|
||||||
|
{
|
||||||
|
return await IGDBAPI<T>(Endpoint, Fields, Query);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1132,12 +1147,15 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
Communications comms = new Communications();
|
Communications comms = new Communications();
|
||||||
switch (_MetadataSource)
|
switch (_MetadataSource)
|
||||||
{
|
{
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.IGDB:
|
case HasheousClient.Models.MetadataSources.IGDB:
|
||||||
await comms.IGDBAPI_GetImage(ImageId, ImagePath);
|
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
|
||||||
break;
|
{
|
||||||
|
await comms.IGDBAPI_GetImage(ImageId, ImagePath);
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.Hasheous:
|
}
|
||||||
await comms.HasheousAPI_GetImage(ImageId, ImagePath);
|
else
|
||||||
|
{
|
||||||
|
await comms.HasheousAPI_GetImage(ImageId, ImagePath);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Company? GetCompanies(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Company? GetCompanies(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cover? GetCover(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Cover? GetCover(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ExternalGame? GetExternalGames(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static ExternalGame? GetExternalGames(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -11,7 +11,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Franchise? GetFranchises(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Franchise? GetFranchises(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameMode? GetGame_Modes(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static GameMode? GetGame_Modes(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameVideo? GetGame_Videos(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static GameVideo? GetGame_Videos(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -20,7 +20,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Game? GetGame(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Game? GetGame(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
@@ -35,7 +35,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Game? GetGame(HasheousClient.Models.MetadataModel.MetadataSources SourceType, string? Slug)
|
public static Game? GetGame(HasheousClient.Models.MetadataSources SourceType, string? Slug)
|
||||||
{
|
{
|
||||||
Game? RetVal = Metadata.GetMetadata<Game>(SourceType, Slug, false);
|
Game? RetVal = Metadata.GetMetadata<Game>(SourceType, Slug, false);
|
||||||
RetVal.MetadataSource = SourceType;
|
RetVal.MetadataSource = SourceType;
|
||||||
@@ -157,67 +157,70 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
|
|
||||||
private static async Task<Game[]> _SearchForGameRemote(string SearchString, long PlatformId, SearchType searchType)
|
private static async Task<Game[]> _SearchForGameRemote(string SearchString, long PlatformId, SearchType searchType)
|
||||||
{
|
{
|
||||||
switch (Communications.MetadataSource)
|
switch (Config.MetadataConfiguration.DefaultMetadataSource)
|
||||||
{
|
{
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.None:
|
case HasheousClient.Models.MetadataSources.None:
|
||||||
return new Game[0];
|
return new Game[0];
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.IGDB:
|
case HasheousClient.Models.MetadataSources.IGDB:
|
||||||
string searchBody = "";
|
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
|
||||||
string searchFields = "fields id,name,slug,platforms,summary; ";
|
|
||||||
bool allowSearch = true;
|
|
||||||
switch (searchType)
|
|
||||||
{
|
{
|
||||||
case SearchType.searchNoPlatform:
|
string searchBody = "";
|
||||||
searchBody = "search \"" + SearchString + "\"; ";
|
string searchFields = "fields id,name,slug,platforms,summary; ";
|
||||||
|
bool allowSearch = true;
|
||||||
allowSearch = AllowNoPlatformSearch;
|
switch (searchType)
|
||||||
break;
|
|
||||||
case SearchType.search:
|
|
||||||
searchBody = "search \"" + SearchString + "\"; where platforms = (" + PlatformId + ");";
|
|
||||||
break;
|
|
||||||
case SearchType.wherefuzzy:
|
|
||||||
searchBody = "where platforms = (" + PlatformId + ") & name ~ *\"" + SearchString + "\"*;";
|
|
||||||
break;
|
|
||||||
case SearchType.where:
|
|
||||||
searchBody = "where platforms = (" + PlatformId + ") & name ~ \"" + SearchString + "\";";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check search cache
|
|
||||||
Game[]? games = Communications.GetSearchCache<Game[]?>(searchFields, searchBody);
|
|
||||||
|
|
||||||
if (games == null)
|
|
||||||
{
|
|
||||||
// cache miss
|
|
||||||
// get Game metadata
|
|
||||||
Communications comms = new Communications();
|
|
||||||
Game[]? results = new Game[0];
|
|
||||||
if (allowSearch == true)
|
|
||||||
{
|
{
|
||||||
results = await comms.APIComm<Game>(IGDB.IGDBClient.Endpoints.Games, searchFields, searchBody);
|
case SearchType.searchNoPlatform:
|
||||||
|
searchBody = "search \"" + SearchString + "\"; ";
|
||||||
|
|
||||||
Communications.SetSearchCache<Game[]?>(searchFields, searchBody, results);
|
allowSearch = AllowNoPlatformSearch;
|
||||||
|
break;
|
||||||
|
case SearchType.search:
|
||||||
|
searchBody = "search \"" + SearchString + "\"; where platforms = (" + PlatformId + ");";
|
||||||
|
break;
|
||||||
|
case SearchType.wherefuzzy:
|
||||||
|
searchBody = "where platforms = (" + PlatformId + ") & name ~ *\"" + SearchString + "\"*;";
|
||||||
|
break;
|
||||||
|
case SearchType.where:
|
||||||
|
searchBody = "where platforms = (" + PlatformId + ") & name ~ \"" + SearchString + "\";";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
// check search cache
|
||||||
|
Game[]? games = Communications.GetSearchCache<Game[]?>(searchFields, searchBody);
|
||||||
|
|
||||||
|
if (games == null)
|
||||||
|
{
|
||||||
|
// cache miss
|
||||||
|
// get Game metadata
|
||||||
|
Communications comms = new Communications();
|
||||||
|
Game[]? results = new Game[0];
|
||||||
|
if (allowSearch == true)
|
||||||
|
{
|
||||||
|
results = await comms.APIComm<Game>(IGDB.IGDBClient.Endpoints.Games, searchFields, searchBody);
|
||||||
|
|
||||||
|
Communications.SetSearchCache<Game[]?>(searchFields, searchBody, results);
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return games.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return games.ToArray();
|
HasheousClient.Hasheous hasheous = new HasheousClient.Hasheous();
|
||||||
|
HasheousClient.Models.Metadata.IGDB.Game[] hResults = hasheous.GetMetadataProxy_SearchGame<HasheousClient.Models.Metadata.IGDB.Game>(HasheousClient.Hasheous.MetadataProvider.IGDB, PlatformId.ToString(), SearchString);
|
||||||
|
|
||||||
|
List<Game> hGames = new List<Game>();
|
||||||
|
foreach (HasheousClient.Models.Metadata.IGDB.Game hResult in hResults)
|
||||||
|
{
|
||||||
|
hGames.Add(Communications.ConvertToIGDBModel<Game>(hResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
return hGames.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.Hasheous:
|
|
||||||
HasheousClient.Hasheous hasheous = new HasheousClient.Hasheous();
|
|
||||||
HasheousClient.Models.Metadata.IGDB.Game[] hResults = hasheous.GetMetadataProxy_SearchGame<HasheousClient.Models.Metadata.IGDB.Game>(HasheousClient.Hasheous.MetadataProvider.IGDB, PlatformId.ToString(), SearchString);
|
|
||||||
|
|
||||||
List<Game> hGames = new List<Game>();
|
|
||||||
foreach (HasheousClient.Models.Metadata.IGDB.Game hResult in hResults)
|
|
||||||
{
|
|
||||||
hGames.Add(Communications.ConvertToIGDBModel<Game>(hResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
return hGames.ToArray();
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new Game[0];
|
return new Game[0];
|
||||||
}
|
}
|
||||||
@@ -396,6 +399,7 @@ ORDER BY Platform.`Name`;";
|
|||||||
public MinimalGameItem(Game gameObject)
|
public MinimalGameItem(Game gameObject)
|
||||||
{
|
{
|
||||||
this.Id = gameObject.Id;
|
this.Id = gameObject.Id;
|
||||||
|
this.MetadataMapId = gameObject.MetadataMapId;
|
||||||
this.Name = gameObject.Name;
|
this.Name = gameObject.Name;
|
||||||
this.Slug = gameObject.Slug;
|
this.Slug = gameObject.Slug;
|
||||||
this.Summary = gameObject.Summary;
|
this.Summary = gameObject.Summary;
|
||||||
@@ -421,6 +425,7 @@ ORDER BY Platform.`Name`;";
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long? Id { get; set; }
|
public long? Id { get; set; }
|
||||||
|
public long? MetadataMapId { get; set; }
|
||||||
public long Index { get; set; }
|
public long Index { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Slug { get; set; }
|
public string Slug { get; set; }
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Genre? GetGenres(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Genre? GetGenres(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +19,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InvolvedCompany? RetVal = Metadata.GetMetadata<InvolvedCompany>(Communications.MetadataSource, (long)Id, false);
|
InvolvedCompany? RetVal = Metadata.GetMetadata<InvolvedCompany>(HasheousClient.Models.MetadataSources.IGDB, (long)Id, false);
|
||||||
return RetVal;
|
return RetVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,19 +5,19 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
#region Exception Handling
|
#region Exception Handling
|
||||||
public class InvalidMetadataId : Exception
|
public class InvalidMetadataId : Exception
|
||||||
{
|
{
|
||||||
public InvalidMetadataId(long Id) : base("Invalid Metadata id: " + Id + " from source: " + Communications.MetadataSource + " (default)")
|
public InvalidMetadataId(long Id) : base("Invalid Metadata id: " + Id + " from source: " + HasheousClient.Models.MetadataSources.IGDB + " (default)")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidMetadataId(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long Id) : base("Invalid Metadata id: " + Id + " from source: " + SourceType)
|
public InvalidMetadataId(HasheousClient.Models.MetadataSources SourceType, long Id) : base("Invalid Metadata id: " + Id + " from source: " + SourceType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidMetadataId(string Id) : base("Invalid Metadata id: " + Id + " from source: " + Communications.MetadataSource + " (default)")
|
public InvalidMetadataId(string Id) : base("Invalid Metadata id: " + Id + " from source: " + HasheousClient.Models.MetadataSources.IGDB + " (default)")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidMetadataId(HasheousClient.Models.MetadataModel.MetadataSources SourceType, string Id) : base("Invalid Metadata id: " + Id + " from source: " + SourceType)
|
public InvalidMetadataId(HasheousClient.Models.MetadataSources SourceType, string Id) : base("Invalid Metadata id: " + Id + " from source: " + SourceType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
throw new InvalidMetadataId(Id);
|
throw new InvalidMetadataId(Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _GetMetadata<T>(Communications.MetadataSource, Id, ForceRefresh);
|
return _GetMetadata<T>(HasheousClient.Models.MetadataSources.IGDB, Id, ForceRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -67,7 +67,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
/// <exception cref="InvalidMetadataId">
|
/// <exception cref="InvalidMetadataId">
|
||||||
/// Thrown when the id is invalid
|
/// Thrown when the id is invalid
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public static T? GetMetadata<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long Id, Boolean ForceRefresh = false) where T : class
|
public static T? GetMetadata<T>(HasheousClient.Models.MetadataSources SourceType, long Id, Boolean ForceRefresh = false) where T : class
|
||||||
{
|
{
|
||||||
if (Id < 0)
|
if (Id < 0)
|
||||||
{
|
{
|
||||||
@@ -77,12 +77,12 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
return _GetMetadata<T>(SourceType, Id, ForceRefresh);
|
return _GetMetadata<T>(SourceType, Id, ForceRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T? GetMetadata<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, string Slug, Boolean ForceRefresh = false) where T : class
|
public static T? GetMetadata<T>(HasheousClient.Models.MetadataSources SourceType, string Slug, Boolean ForceRefresh = false) where T : class
|
||||||
{
|
{
|
||||||
return _GetMetadata<T>(SourceType, Slug, ForceRefresh);
|
return _GetMetadata<T>(SourceType, Slug, ForceRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static T? _GetMetadata<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, object Id, Boolean ForceRefresh) where T : class
|
private static T? _GetMetadata<T>(HasheousClient.Models.MetadataSources SourceType, object Id, Boolean ForceRefresh) where T : class
|
||||||
{
|
{
|
||||||
// get T type as string
|
// get T type as string
|
||||||
string type = typeof(T).Name;
|
string type = typeof(T).Name;
|
||||||
@@ -160,7 +160,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
String
|
String
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<T> GetMetadataFromServer<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long Id) where T : class
|
private static async Task<T> GetMetadataFromServer<T>(HasheousClient.Models.MetadataSources SourceType, long Id) where T : class
|
||||||
{
|
{
|
||||||
// get T type as string
|
// get T type as string
|
||||||
string type = typeof(T).Name;
|
string type = typeof(T).Name;
|
||||||
@@ -178,7 +178,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
return results.FirstOrDefault<T>();
|
return results.FirstOrDefault<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<T> GetMetadataFromServer<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, string Id) where T : class
|
private static async Task<T> GetMetadataFromServer<T>(HasheousClient.Models.MetadataSources SourceType, string Id) where T : class
|
||||||
{
|
{
|
||||||
// get T type as string
|
// get T type as string
|
||||||
string type = typeof(T).Name;
|
string type = typeof(T).Name;
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MultiplayerMode? GetGame_MultiplayerModes(long? Id)
|
public static MultiplayerMode? GetGame_MultiplayerModes(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MultiplayerMode? RetVal = Metadata.GetMetadata<MultiplayerMode>(Communications.MetadataSource, (long)Id, false);
|
MultiplayerMode? RetVal = Metadata.GetMetadata<MultiplayerMode>(SourceType, (long)Id, false);
|
||||||
return RetVal;
|
return RetVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformLogo? RetVal = Metadata.GetMetadata<PlatformLogo>(Communications.MetadataSource, (long)Id, false);
|
PlatformLogo? RetVal = Metadata.GetMetadata<PlatformLogo>(HasheousClient.Models.MetadataSources.IGDB, (long)Id, false);
|
||||||
return RetVal;
|
return RetVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlatformVersion? GetPlatformVersion(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long Id)
|
public static PlatformVersion? GetPlatformVersion(HasheousClient.Models.MetadataSources SourceType, long Id)
|
||||||
{
|
{
|
||||||
if (Id == 0)
|
if (Id == 0)
|
||||||
{
|
{
|
||||||
|
@@ -22,7 +22,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Platform? RetVal = Metadata.GetMetadata<Platform>(Communications.MetadataSource, (long)Id, false);
|
Platform? RetVal = Metadata.GetMetadata<Platform>(HasheousClient.Models.MetadataSources.IGDB, (long)Id, false);
|
||||||
return RetVal;
|
return RetVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
// get platform id from slug - query Platform table
|
// get platform id from slug - query Platform table
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
string query = "SELECT Id FROM Platform WHERE slug = @slug AND SourceId = @sourceid;";
|
string query = "SELECT Id FROM Platform WHERE slug = @slug AND SourceId = @sourceid;";
|
||||||
DataTable result = db.ExecuteCMD(query, new Dictionary<string, object> { { "@slug", Slug }, { "@sourceid", Communications.MetadataSource } });
|
DataTable result = db.ExecuteCMD(query, new Dictionary<string, object> { { "@slug", Slug }, { "@sourceid", HasheousClient.Models.MetadataSources.IGDB } });
|
||||||
if (result.Rows.Count == 0)
|
if (result.Rows.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Metadata.InvalidMetadataId(Slug);
|
throw new Metadata.InvalidMetadataId(Slug);
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerPerspective? GetGame_PlayerPerspectives(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static PlayerPerspective? GetGame_PlayerPerspectives(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReleaseDate? GetReleaseDates(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static ReleaseDate? GetReleaseDates(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Screenshot? GetScreenshot(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Screenshot? GetScreenshot(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -45,7 +45,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// The cache status of the record
|
/// The cache status of the record
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static CacheStatus GetCacheStatus(HasheousClient.Models.MetadataModel.MetadataSources SourceType, string Endpoint, string Slug)
|
public static CacheStatus GetCacheStatus(HasheousClient.Models.MetadataSources SourceType, string Endpoint, string Slug)
|
||||||
{
|
{
|
||||||
return _GetCacheStatus(SourceType, Endpoint, "slug", Slug);
|
return _GetCacheStatus(SourceType, Endpoint, "slug", Slug);
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// The cache status of the record
|
/// The cache status of the record
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static CacheStatus GetCacheStatus(HasheousClient.Models.MetadataModel.MetadataSources SourceType, string Endpoint, long Id)
|
public static CacheStatus GetCacheStatus(HasheousClient.Models.MetadataSources SourceType, string Endpoint, long Id)
|
||||||
{
|
{
|
||||||
return _GetCacheStatus(SourceType, Endpoint, "id", Id);
|
return _GetCacheStatus(SourceType, Endpoint, "id", Id);
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CacheStatus _GetCacheStatus(HasheousClient.Models.MetadataModel.MetadataSources SourceType, string Endpoint, string SearchField, object SearchValue)
|
private static CacheStatus _GetCacheStatus(HasheousClient.Models.MetadataSources SourceType, string Endpoint, string SearchField, object SearchValue)
|
||||||
{
|
{
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
/// <param name="UpdateRecord">
|
/// <param name="UpdateRecord">
|
||||||
/// Whether to update the record if it already exists
|
/// Whether to update the record if it already exists
|
||||||
/// </param>
|
/// </param>
|
||||||
public static void NewCacheValue<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, T ObjectToCache, bool UpdateRecord = false)
|
public static void NewCacheValue<T>(HasheousClient.Models.MetadataSources SourceType, T ObjectToCache, bool UpdateRecord = false)
|
||||||
{
|
{
|
||||||
// get the object type name
|
// get the object type name
|
||||||
string ObjectTypeName = ObjectToCache.GetType().Name;
|
string ObjectTypeName = ObjectToCache.GetType().Name;
|
||||||
@@ -182,7 +182,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
fieldList = fieldList + key.Key;
|
fieldList = fieldList + key.Key;
|
||||||
valueList = valueList + "@" + key.Key;
|
valueList = valueList + "@" + key.Key;
|
||||||
if ((key.Key != "id") && (key.Key != "dateAdded"))
|
if ((key.Key != "id") && (key.Key != "dateAdded") && (key.Key != "SourceId"))
|
||||||
{
|
{
|
||||||
if (updateFieldValueList.Length > 0)
|
if (updateFieldValueList.Length > 0)
|
||||||
{
|
{
|
||||||
@@ -239,11 +239,11 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
string sql = "";
|
string sql = "";
|
||||||
if (UpdateRecord == false)
|
if (UpdateRecord == false)
|
||||||
{
|
{
|
||||||
sql = "INSERT INTO " + ObjectTypeName + " (" + fieldList + ") VALUES (" + valueList + ")";
|
sql = "INSERT INTO " + ObjectTypeName + " (" + fieldList + ") VALUES (" + valueList + ");";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sql = "UPDATE " + ObjectTypeName + " SET " + updateFieldValueList + " WHERE Id = @Id";
|
sql = "UPDATE " + ObjectTypeName + " SET " + updateFieldValueList + " WHERE Id = @Id AND SourceId = @SourceId;";
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute sql
|
// execute sql
|
||||||
@@ -275,7 +275,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
/// <exception cref="Exception">
|
/// <exception cref="Exception">
|
||||||
/// Thrown when no record is found that matches the search criteria
|
/// Thrown when no record is found that matches the search criteria
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public static T GetCacheValue<T>(HasheousClient.Models.MetadataModel.MetadataSources SourceType, T? EndpointType, string SearchField, object SearchValue)
|
public static T GetCacheValue<T>(HasheousClient.Models.MetadataSources SourceType, T? EndpointType, string SearchField, object SearchValue)
|
||||||
{
|
{
|
||||||
string Endpoint = EndpointType.GetType().Name;
|
string Endpoint = EndpointType.GetType().Name;
|
||||||
|
|
||||||
@@ -311,55 +311,58 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
if (property.GetCustomAttribute<Models.NoDatabaseAttribute>() == null)
|
if (property.GetCustomAttribute<Models.NoDatabaseAttribute>() == null)
|
||||||
{
|
{
|
||||||
// get the value from the DataRow with the same name as the property
|
// get the value from the DataRow with the same name as the property
|
||||||
object? value = dataRow[property.Name];
|
if (dataRow.Table.Columns.Contains(property.Name) == true)
|
||||||
|
|
||||||
if (value != null && value != DBNull.Value)
|
|
||||||
{
|
{
|
||||||
// check the property type - if it's a list or array, deserialize it. Otherwise, just set the value
|
object? value = dataRow[property.Name];
|
||||||
Type objectType = EndpointType.GetType();
|
|
||||||
if (objectType != null)
|
if (value != null && value != DBNull.Value)
|
||||||
{
|
{
|
||||||
// fullname = System.Nullable`1[[System.DateTimeOffset,
|
// check the property type - if it's a list or array, deserialize it. Otherwise, just set the value
|
||||||
string propertyTypeName = property.PropertyType.FullName.Split(",")[0];
|
Type objectType = EndpointType.GetType();
|
||||||
bool isNullable = false;
|
if (objectType != null)
|
||||||
if (propertyTypeName.StartsWith("System.Nullable"))
|
|
||||||
{
|
{
|
||||||
isNullable = true;
|
// fullname = System.Nullable`1[[System.DateTimeOffset,
|
||||||
propertyTypeName = propertyTypeName.Split("[[")[1];
|
string propertyTypeName = property.PropertyType.FullName.Split(",")[0];
|
||||||
}
|
bool isNullable = false;
|
||||||
propertyTypeName = propertyTypeName.Split("`")[0];
|
if (propertyTypeName.StartsWith("System.Nullable"))
|
||||||
|
{
|
||||||
|
isNullable = true;
|
||||||
|
propertyTypeName = propertyTypeName.Split("[[")[1];
|
||||||
|
}
|
||||||
|
propertyTypeName = propertyTypeName.Split("`")[0];
|
||||||
|
|
||||||
switch (propertyTypeName.ToLower())
|
switch (propertyTypeName.ToLower())
|
||||||
{
|
{
|
||||||
case "system.collections.generic.list":
|
case "system.collections.generic.list":
|
||||||
var listArray = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(value.ToString());
|
var listArray = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(value.ToString());
|
||||||
property.SetValue(EndpointType, listArray);
|
property.SetValue(EndpointType, listArray);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "system.int32[]":
|
case "system.int32[]":
|
||||||
var int32array = Newtonsoft.Json.JsonConvert.DeserializeObject<int[]>(value.ToString());
|
var int32array = Newtonsoft.Json.JsonConvert.DeserializeObject<int[]>(value.ToString());
|
||||||
property.SetValue(EndpointType, int32array);
|
property.SetValue(EndpointType, int32array);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "system.datetimeoffset":
|
case "system.datetimeoffset":
|
||||||
property.SetValue(EndpointType, (DateTimeOffset)(DateTime?)value);
|
property.SetValue(EndpointType, (DateTimeOffset)(DateTime?)value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// check if property is an enum
|
// check if property is an enum
|
||||||
if (property.PropertyType.IsEnum)
|
if (property.PropertyType.IsEnum)
|
||||||
{
|
{
|
||||||
property.SetValue(EndpointType, Enum.Parse(property.PropertyType, value.ToString()));
|
property.SetValue(EndpointType, Enum.Parse(property.PropertyType, value.ToString()));
|
||||||
}
|
}
|
||||||
else if (Common.IsNullableEnum(property.PropertyType))
|
else if (Common.IsNullableEnum(property.PropertyType))
|
||||||
{
|
{
|
||||||
property.SetValue(EndpointType, Enum.Parse(Nullable.GetUnderlyingType(property.PropertyType), value.ToString()));
|
property.SetValue(EndpointType, Enum.Parse(Nullable.GetUnderlyingType(property.PropertyType), value.ToString()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
property.SetValue(EndpointType, value);
|
property.SetValue(EndpointType, value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Theme? GetGame_Themes(HasheousClient.Models.MetadataModel.MetadataSources SourceType, long? Id)
|
public static Theme? GetGame_Themes(HasheousClient.Models.MetadataSources SourceType, long? Id)
|
||||||
{
|
{
|
||||||
if ((Id == 0) || (Id == null))
|
if ((Id == 0) || (Id == null))
|
||||||
{
|
{
|
||||||
|
@@ -2,11 +2,202 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using gaseous_server.Classes.Metadata;
|
using gaseous_server.Classes.Metadata;
|
||||||
using gaseous_server.Models;
|
using gaseous_server.Models;
|
||||||
|
using HasheousClient.Models;
|
||||||
|
using HasheousClient.Models.Metadata.IGDB;
|
||||||
|
|
||||||
namespace gaseous_server.Classes
|
namespace gaseous_server.Classes
|
||||||
{
|
{
|
||||||
public class MetadataManagement : QueueItemStatus
|
public class MetadataManagement : QueueItemStatus
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new metadata map, if one with the same platformId and name does not already exist.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="platformId">
|
||||||
|
/// The ID of the platform to which the metadata map belongs.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="name">
|
||||||
|
/// The name of the metadata map.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// The ID of the new metadata map, or the ID of the existing metadata map if one already exists.
|
||||||
|
/// </returns>
|
||||||
|
public static MetadataMap? NewMetadataMap(long platformId, string name)
|
||||||
|
{
|
||||||
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
string sql = "";
|
||||||
|
Dictionary<string, object> dbDict = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "@platformId", platformId },
|
||||||
|
{ "@name", name }
|
||||||
|
};
|
||||||
|
DataTable dt = new DataTable();
|
||||||
|
|
||||||
|
// check if the metadata map already exists
|
||||||
|
MetadataMap? existingMetadataMap = GetMetadataMap(platformId, name);
|
||||||
|
if (existingMetadataMap != null)
|
||||||
|
{
|
||||||
|
return existingMetadataMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the metadata map
|
||||||
|
sql = "INSERT INTO MetadataMap (PlatformId, SignatureGameName) VALUES (@platformId, @name); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||||
|
dt = db.ExecuteCMD(sql, dbDict);
|
||||||
|
|
||||||
|
long metadataMapId = (long)dt.Rows[0][0];
|
||||||
|
|
||||||
|
// create dummy game metadata item and capture id
|
||||||
|
sql = "INSERT INTO Game (SourceId, Name) VALUES (@sourceid, @name); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||||
|
dbDict = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "@sourceid", HasheousClient.Models.MetadataSources.None },
|
||||||
|
{ "@name", name }
|
||||||
|
};
|
||||||
|
dt = db.ExecuteCMD(sql, dbDict);
|
||||||
|
|
||||||
|
long gameId = (long)dt.Rows[0][0];
|
||||||
|
|
||||||
|
// add default metadata sources
|
||||||
|
AddMetadataMapItem(metadataMapId, HasheousClient.Models.MetadataSources.None, gameId, true);
|
||||||
|
|
||||||
|
// return the new metadata map
|
||||||
|
return GetMetadataMap(metadataMapId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a metadata map item to the database.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="metadataMapId">
|
||||||
|
/// The ID of the metadata map to which the item belongs.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="sourceType">
|
||||||
|
/// The type of the metadata source.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="sourceId">
|
||||||
|
/// The ID of the metadata source.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="preferred">
|
||||||
|
/// Whether the metadata source is preferred.
|
||||||
|
/// </param>
|
||||||
|
/// <remarks>
|
||||||
|
/// If the metadata source is preferred, all other metadata sources for the same metadata map will be set to not preferred.
|
||||||
|
/// </remarks>
|
||||||
|
public static void AddMetadataMapItem(long metadataMapId, HasheousClient.Models.MetadataSources sourceType, long sourceId, bool preferred)
|
||||||
|
{
|
||||||
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
string sql = "";
|
||||||
|
Dictionary<string, object> dbDict = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "@metadataMapId", metadataMapId },
|
||||||
|
{ "@sourceType", sourceType },
|
||||||
|
{ "@sourceId", sourceId },
|
||||||
|
{ "@preferred", preferred },
|
||||||
|
{ "@processedatimport", false }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (preferred == true)
|
||||||
|
{
|
||||||
|
// set all other items to not preferred
|
||||||
|
sql = "UPDATE MetadataMapBridge SET Preferred = 0 WHERE ParentMapId = @metadataMapId;";
|
||||||
|
db.ExecuteCMD(sql, dbDict);
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = "INSERT INTO MetadataMapBridge (ParentMapId, MetadataSourceType, MetadataSourceId, Preferred, ProcessedAtImport) VALUES (@metadataMapId, @sourceType, @sourceId, @preferred, @processedatimport);";
|
||||||
|
db.ExecuteCMD(sql, dbDict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a metadata map from the database.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="platformId">
|
||||||
|
/// The ID of the platform to which the metadata map belongs.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="name">
|
||||||
|
/// The name of the metadata map.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// The metadata map, or null if it does not exist.
|
||||||
|
/// </returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// This method will return the first metadata map found with the given platformId and name.
|
||||||
|
/// </remarks>
|
||||||
|
public static MetadataMap? GetMetadataMap(long platformId, string name)
|
||||||
|
{
|
||||||
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
string sql = "";
|
||||||
|
Dictionary<string, object> dbDict = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "@platformId", platformId },
|
||||||
|
{ "@name", name }
|
||||||
|
};
|
||||||
|
DataTable dt = new DataTable();
|
||||||
|
|
||||||
|
sql = "SELECT Id FROM MetadataMap WHERE PlatformId = @platformId AND SignatureGameName = @name;";
|
||||||
|
dt = db.ExecuteCMD(sql, dbDict);
|
||||||
|
|
||||||
|
if (dt.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
return GetMetadataMap((long)dt.Rows[0]["Id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a metadata map from the database.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="metadataMapId">
|
||||||
|
/// The ID of the metadata map.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// The metadata map, or null if it does not exist.
|
||||||
|
/// </returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// This method will return the metadata map with the given ID.
|
||||||
|
/// </remarks>
|
||||||
|
public static MetadataMap? GetMetadataMap(long metadataMapId)
|
||||||
|
{
|
||||||
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
string sql = "";
|
||||||
|
Dictionary<string, object> dbDict = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "@metadataMapId", metadataMapId }
|
||||||
|
};
|
||||||
|
DataTable dt = new DataTable();
|
||||||
|
|
||||||
|
sql = "SELECT * FROM MetadataMap WHERE Id = @metadataMapId;";
|
||||||
|
dt = db.ExecuteCMD(sql, dbDict);
|
||||||
|
|
||||||
|
if (dt.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
MetadataMap metadataMap = new MetadataMap()
|
||||||
|
{
|
||||||
|
Id = (long)dt.Rows[0]["Id"],
|
||||||
|
PlatformId = (long)dt.Rows[0]["PlatformId"],
|
||||||
|
SignatureGameName = dt.Rows[0]["SignatureGameName"].ToString(),
|
||||||
|
MetadataMapItems = new List<MetadataMap.MetadataMapItem>()
|
||||||
|
};
|
||||||
|
|
||||||
|
sql = "SELECT * FROM MetadataMapBridge WHERE ParentMapId = @metadataMapId;";
|
||||||
|
dt = db.ExecuteCMD(sql, dbDict);
|
||||||
|
|
||||||
|
foreach (DataRow dr in dt.Rows)
|
||||||
|
{
|
||||||
|
MetadataMap.MetadataMapItem metadataMapItem = new MetadataMap.MetadataMapItem()
|
||||||
|
{
|
||||||
|
SourceType = (HasheousClient.Models.MetadataSources)dr["MetadataSourceType"],
|
||||||
|
SourceId = (long)dr["MetadataSourceId"],
|
||||||
|
Preferred = (bool)dr["Preferred"]
|
||||||
|
};
|
||||||
|
|
||||||
|
metadataMap.MetadataMapItems.Add(metadataMapItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadataMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void RefreshMetadata(bool forceRefresh = false)
|
public void RefreshMetadata(bool forceRefresh = false)
|
||||||
{
|
{
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
@@ -59,8 +250,102 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
MetadataSources metadataSource = MetadataSources.IGDB;
|
||||||
Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for game " + dr["name"] + " (" + dr["id"] + ")");
|
Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for game " + dr["name"] + " (" + dr["id"] + ")");
|
||||||
Metadata.Games.GetGame(Communications.MetadataSource, (long)dr["id"]);
|
HasheousClient.Models.Metadata.IGDB.Game game = Metadata.Games.GetGame(metadataSource, (long)dr["id"]);
|
||||||
|
|
||||||
|
// get supporting metadata
|
||||||
|
if (game != null)
|
||||||
|
{
|
||||||
|
if (game.AgeRatings != null)
|
||||||
|
{
|
||||||
|
foreach (long ageRatingId in game.AgeRatings)
|
||||||
|
{
|
||||||
|
AgeRating ageRating = Metadata.AgeRatings.GetAgeRating(metadataSource, ageRatingId);
|
||||||
|
if (ageRating.ContentDescriptions != null)
|
||||||
|
{
|
||||||
|
foreach (long ageRatingContentDescriptionId in ageRating.ContentDescriptions)
|
||||||
|
{
|
||||||
|
Metadata.AgeRatingContentDescriptions.GetAgeRatingContentDescriptions(metadataSource, ageRatingContentDescriptionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.AlternativeNames != null)
|
||||||
|
{
|
||||||
|
foreach (long alternateNameId in game.AlternativeNames)
|
||||||
|
{
|
||||||
|
Metadata.AlternativeNames.GetAlternativeNames(metadataSource, alternateNameId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.Artworks != null)
|
||||||
|
{
|
||||||
|
foreach (long artworkId in game.Artworks)
|
||||||
|
{
|
||||||
|
Metadata.Artworks.GetArtwork(metadataSource, artworkId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.Cover != null)
|
||||||
|
{
|
||||||
|
Metadata.Covers.GetCover(metadataSource, (long?)game.Cover);
|
||||||
|
}
|
||||||
|
if (game.GameModes != null)
|
||||||
|
{
|
||||||
|
foreach (long gameModeId in game.GameModes)
|
||||||
|
{
|
||||||
|
Metadata.GameModes.GetGame_Modes(metadataSource, gameModeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.Genres != null)
|
||||||
|
{
|
||||||
|
foreach (long genreId in game.Genres)
|
||||||
|
{
|
||||||
|
Metadata.Genres.GetGenres(metadataSource, genreId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.Videos != null)
|
||||||
|
{
|
||||||
|
foreach (long gameVideoId in game.Videos)
|
||||||
|
{
|
||||||
|
Metadata.GamesVideos.GetGame_Videos(metadataSource, gameVideoId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.MultiplayerModes != null)
|
||||||
|
{
|
||||||
|
foreach (long multiplayerModeId in game.MultiplayerModes)
|
||||||
|
{
|
||||||
|
Metadata.MultiplayerModes.GetGame_MultiplayerModes(metadataSource, multiplayerModeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.PlayerPerspectives != null)
|
||||||
|
{
|
||||||
|
foreach (long playerPerspectiveId in game.PlayerPerspectives)
|
||||||
|
{
|
||||||
|
Metadata.PlayerPerspectives.GetGame_PlayerPerspectives(metadataSource, playerPerspectiveId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.ReleaseDates != null)
|
||||||
|
{
|
||||||
|
foreach (long releaseDateId in game.ReleaseDates)
|
||||||
|
{
|
||||||
|
Metadata.ReleaseDates.GetReleaseDates(metadataSource, releaseDateId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.Screenshots != null)
|
||||||
|
{
|
||||||
|
foreach (long screenshotId in game.Screenshots)
|
||||||
|
{
|
||||||
|
Metadata.Screenshots.GetScreenshot(metadataSource, screenshotId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.Themes != null)
|
||||||
|
{
|
||||||
|
foreach (long themeId in game.Themes)
|
||||||
|
{
|
||||||
|
Metadata.Themes.GetGame_Themes(metadataSource, themeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@@ -296,7 +296,7 @@ namespace gaseous_server.Classes
|
|||||||
GameRomMediaGroupItem mediaGroupItem = GetMediaGroup(Id);
|
GameRomMediaGroupItem mediaGroupItem = GetMediaGroup(Id);
|
||||||
if (mediaGroupItem.Status == GameRomMediaGroupItem.GroupBuildStatus.WaitingForBuild)
|
if (mediaGroupItem.Status == GameRomMediaGroupItem.GroupBuildStatus.WaitingForBuild)
|
||||||
{
|
{
|
||||||
Models.Game GameObject = Games.GetGame(Communications.MetadataSource, mediaGroupItem.GameId);
|
Models.Game GameObject = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, mediaGroupItem.GameId);
|
||||||
Platform PlatformObject = Platforms.GetPlatform(mediaGroupItem.PlatformId);
|
Platform PlatformObject = Platforms.GetPlatform(mediaGroupItem.PlatformId);
|
||||||
PlatformMapping.PlatformMapItem platformMapItem = PlatformMapping.GetPlatformMap(mediaGroupItem.PlatformId);
|
PlatformMapping.PlatformMapItem platformMapItem = PlatformMapping.GetPlatformMap(mediaGroupItem.PlatformId);
|
||||||
|
|
||||||
|
@@ -113,7 +113,7 @@ namespace gaseous_server.Classes
|
|||||||
public static GameRomItem GetRom(long RomId)
|
public static GameRomItem GetRom(long RomId)
|
||||||
{
|
{
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
string sql = "SELECT view_Games_Roms.*, Platform.`Name` AS platformname, Game.`Name` AS gamename FROM view_Games_Roms LEFT JOIN Platform ON view_Games_Roms.PlatformId = Platform.Id LEFT JOIN Game ON view_Games_Roms.GameId = Game.Id WHERE view_Games_Roms.Id = @id";
|
string sql = "SELECT DISTINCT view_Games_Roms.*, Platform.`Name` AS platformname, view_GamesWithRoms.`Name` AS gamename FROM view_Games_Roms LEFT JOIN Platform ON view_Games_Roms.PlatformId = Platform.Id LEFT JOIN view_GamesWithRoms ON view_Games_Roms.GameId = view_GamesWithRoms.Id WHERE view_Games_Roms.Id = @id";
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||||
dbDict.Add("id", RomId);
|
dbDict.Add("id", RomId);
|
||||||
DataTable romDT = db.ExecuteCMD(sql, dbDict);
|
DataTable romDT = db.ExecuteCMD(sql, dbDict);
|
||||||
@@ -133,7 +133,7 @@ namespace gaseous_server.Classes
|
|||||||
public static GameRomItem GetRom(string MD5)
|
public static GameRomItem GetRom(string MD5)
|
||||||
{
|
{
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
string sql = "SELECT view_Games_Roms.*, Platform.`Name` AS platformname, Game.`Name` AS gamename FROM view_Games_Roms LEFT JOIN Platform ON view_Games_Roms.PlatformId = Platform.Id LEFT JOIN Game ON view_Games_Roms.GameId = Game.Id WHERE view_Games_Roms.MD5 = @id";
|
string sql = "SELECT DISTINCT view_Games_Roms.*, Platform.`Name` AS platformname, view_GamesWithRoms.`Name` AS gamename FROM view_Games_Roms LEFT JOIN Platform ON view_Games_Roms.PlatformId = Platform.Id LEFT JOIN view_GamesWithRoms ON view_Games_Roms.GameId = view_GamesWithRoms.Id WHERE view_Games_Roms.MD5 = @id";
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||||
dbDict.Add("id", MD5);
|
dbDict.Add("id", MD5);
|
||||||
DataTable romDT = db.ExecuteCMD(sql, dbDict);
|
DataTable romDT = db.ExecuteCMD(sql, dbDict);
|
||||||
@@ -156,7 +156,7 @@ namespace gaseous_server.Classes
|
|||||||
HasheousClient.Models.Metadata.IGDB.Platform platform = Classes.Metadata.Platforms.GetPlatform(PlatformId);
|
HasheousClient.Models.Metadata.IGDB.Platform platform = Classes.Metadata.Platforms.GetPlatform(PlatformId);
|
||||||
|
|
||||||
// ensure metadata for gameid is present
|
// ensure metadata for gameid is present
|
||||||
Models.Game game = Classes.Metadata.Games.GetGame(Communications.MetadataSource, GameId);
|
Models.Game game = Classes.Metadata.Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, GameId);
|
||||||
|
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
string sql = "UPDATE Games_Roms SET PlatformId=@platformid, GameId=@gameid WHERE Id = @id";
|
string sql = "UPDATE Games_Roms SET PlatformId=@platformid, GameId=@gameid WHERE Id = @id";
|
||||||
|
@@ -61,7 +61,7 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
NowPlaying = new Models.UserProfile.NowPlayingItem
|
NowPlaying = new Models.UserProfile.NowPlayingItem
|
||||||
{
|
{
|
||||||
Game = Games.GetGame(Communications.MetadataSource, (long)nowPlayingData.Rows[0]["GameId"]),
|
Game = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, (long)nowPlayingData.Rows[0]["GameId"]),
|
||||||
Platform = Platforms.GetPlatform((long)nowPlayingData.Rows[0]["PlatformId"]),
|
Platform = Platforms.GetPlatform((long)nowPlayingData.Rows[0]["PlatformId"]),
|
||||||
Duration = Convert.ToInt64(nowPlayingData.Rows[0]["SessionLength"])
|
Duration = Convert.ToInt64(nowPlayingData.Rows[0]["SessionLength"])
|
||||||
};
|
};
|
||||||
|
@@ -1562,7 +1562,7 @@ namespace gaseous_server.Controllers
|
|||||||
Common.hashObject hash = new Common.hashObject(romItem.Path);
|
Common.hashObject hash = new Common.hashObject(romItem.Path);
|
||||||
FileSignature fileSignature = new FileSignature();
|
FileSignature fileSignature = new FileSignature();
|
||||||
gaseous_server.Models.Signatures_Games romSig = fileSignature.GetFileSignature(romItem.Library, hash, new FileInfo(romItem.Path), romItem.Path);
|
gaseous_server.Models.Signatures_Games romSig = fileSignature.GetFileSignature(romItem.Library, hash, new FileInfo(romItem.Path), romItem.Path);
|
||||||
List<gaseous_server.Models.Game> searchResults = Classes.ImportGame.SearchForGame_GetAll(romSig.Game.Name, romSig.Flags.IGDBPlatformId);
|
List<gaseous_server.Models.Game> searchResults = Classes.ImportGame.SearchForGame_GetAll(romSig.Game.Name, romSig.Flags.PlatformId);
|
||||||
|
|
||||||
return Ok(searchResults);
|
return Ok(searchResults);
|
||||||
}
|
}
|
||||||
|
@@ -77,9 +77,9 @@ namespace gaseous_server.Controllers
|
|||||||
if (RetVal["status"] == "imported")
|
if (RetVal["status"] == "imported")
|
||||||
{
|
{
|
||||||
gaseous_server.Models.Game? game = (gaseous_server.Models.Game)RetVal["game"];
|
gaseous_server.Models.Game? game = (gaseous_server.Models.Game)RetVal["game"];
|
||||||
if (game.Id == null)
|
if (game == null || game.Id == null)
|
||||||
{
|
{
|
||||||
RetVal["game"] = Games.GetGame(Communications.MetadataSource, 0);
|
RetVal["game"] = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -64,77 +64,81 @@ namespace gaseous_server.Controllers
|
|||||||
|
|
||||||
private static async Task<List<gaseous_server.Models.Game>> _SearchForGame(long PlatformId, string SearchString)
|
private static async Task<List<gaseous_server.Models.Game>> _SearchForGame(long PlatformId, string SearchString)
|
||||||
{
|
{
|
||||||
switch (Communications.MetadataSource)
|
switch (Config.MetadataConfiguration.DefaultMetadataSource)
|
||||||
{
|
{
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.IGDB:
|
case HasheousClient.Models.MetadataSources.IGDB:
|
||||||
string searchBody = "";
|
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
|
||||||
string searchFields = "fields *; ";
|
|
||||||
searchBody += "search \"" + SearchString + "\";";
|
|
||||||
searchBody += "where platforms = (" + PlatformId + ");";
|
|
||||||
searchBody += "limit 100;";
|
|
||||||
|
|
||||||
List<gaseous_server.Models.Game>? searchCache = Communications.GetSearchCache<List<gaseous_server.Models.Game>>(searchFields, searchBody);
|
|
||||||
|
|
||||||
if (searchCache == null)
|
|
||||||
{
|
{
|
||||||
// cache miss
|
string searchBody = "";
|
||||||
// get Game metadata from data source
|
string searchFields = "fields *; ";
|
||||||
Communications comms = new Communications();
|
searchBody += "search \"" + SearchString + "\";";
|
||||||
var results = await comms.APIComm<gaseous_server.Models.Game>("Game", searchFields, searchBody);
|
searchBody += "where platforms = (" + PlatformId + ");";
|
||||||
|
searchBody += "limit 100;";
|
||||||
|
|
||||||
List<gaseous_server.Models.Game> games = new List<gaseous_server.Models.Game>();
|
List<gaseous_server.Models.Game>? searchCache = Communications.GetSearchCache<List<gaseous_server.Models.Game>>(searchFields, searchBody);
|
||||||
foreach (gaseous_server.Models.Game game in results.ToList())
|
|
||||||
|
if (searchCache == null)
|
||||||
{
|
{
|
||||||
Storage.CacheStatus cacheStatus = Storage.GetCacheStatus(Communications.MetadataSource, "Game", (long)game.Id);
|
// cache miss
|
||||||
switch (cacheStatus)
|
// get Game metadata from data source
|
||||||
|
Communications comms = new Communications();
|
||||||
|
var results = await comms.APIComm<gaseous_server.Models.Game>("Game", searchFields, searchBody);
|
||||||
|
|
||||||
|
List<gaseous_server.Models.Game> games = new List<gaseous_server.Models.Game>();
|
||||||
|
foreach (gaseous_server.Models.Game game in results.ToList())
|
||||||
{
|
{
|
||||||
case Storage.CacheStatus.NotPresent:
|
Storage.CacheStatus cacheStatus = Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.IGDB, "Game", (long)game.Id);
|
||||||
Storage.NewCacheValue(Communications.MetadataSource, game, false);
|
switch (cacheStatus)
|
||||||
break;
|
{
|
||||||
|
case Storage.CacheStatus.NotPresent:
|
||||||
|
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.IGDB, game, false);
|
||||||
|
break;
|
||||||
|
|
||||||
case Storage.CacheStatus.Expired:
|
case Storage.CacheStatus.Expired:
|
||||||
Storage.NewCacheValue(Communications.MetadataSource, game, true);
|
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.IGDB, game, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
games.Add(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
games.Add(game);
|
Communications.SetSearchCache<List<gaseous_server.Models.Game>>(searchFields, searchBody, games);
|
||||||
|
|
||||||
|
return games;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// get full version of results from database
|
||||||
|
// this is a hacky workaround due to the readonly nature of IGDB.Model.Game IdentityOrValue fields
|
||||||
|
List<gaseous_server.Models.Game> gamesToReturn = new List<gaseous_server.Models.Game>();
|
||||||
|
foreach (gaseous_server.Models.Game game in searchCache)
|
||||||
|
{
|
||||||
|
gaseous_server.Models.Game? tempGame = Games.GetGame(Communications.MetadataSource, (long)game.Id);
|
||||||
|
if (tempGame != null)
|
||||||
|
{
|
||||||
|
gamesToReturn.Add(tempGame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Communications.SetSearchCache<List<gaseous_server.Models.Game>>(searchFields, searchBody, games);
|
return gamesToReturn;
|
||||||
|
}
|
||||||
return games;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get full version of results from database
|
HasheousClient.Hasheous hasheous = new HasheousClient.Hasheous();
|
||||||
// this is a hacky workaround due to the readonly nature of IGDB.Model.Game IdentityOrValue fields
|
Communications.ConfigureHasheousClient(ref hasheous);
|
||||||
List<gaseous_server.Models.Game> gamesToReturn = new List<gaseous_server.Models.Game>();
|
List<gaseous_server.Models.Game> hSearch = hasheous.GetMetadataProxy_SearchGame<gaseous_server.Models.Game>(HasheousClient.Hasheous.MetadataProvider.IGDB, PlatformId.ToString(), SearchString).ToList<gaseous_server.Models.Game>();
|
||||||
foreach (gaseous_server.Models.Game game in searchCache)
|
|
||||||
|
List<gaseous_server.Models.Game> hGamesToReturn = new List<gaseous_server.Models.Game>();
|
||||||
|
foreach (gaseous_server.Models.Game game in hSearch)
|
||||||
{
|
{
|
||||||
gaseous_server.Models.Game? tempGame = Games.GetGame(Communications.MetadataSource, (long)game.Id);
|
hGamesToReturn.Add(game);
|
||||||
if (tempGame != null)
|
|
||||||
{
|
|
||||||
gamesToReturn.Add(tempGame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return gamesToReturn;
|
return hGamesToReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
case HasheousClient.Models.MetadataModel.MetadataSources.Hasheous:
|
|
||||||
HasheousClient.Hasheous hasheous = new HasheousClient.Hasheous();
|
|
||||||
Communications.ConfigureHasheousClient(ref hasheous);
|
|
||||||
List<gaseous_server.Models.Game> hSearch = hasheous.GetMetadataProxy_SearchGame<gaseous_server.Models.Game>(HasheousClient.Hasheous.MetadataProvider.IGDB, PlatformId.ToString(), SearchString).ToList<gaseous_server.Models.Game>();
|
|
||||||
|
|
||||||
List<gaseous_server.Models.Game> hGamesToReturn = new List<gaseous_server.Models.Game>();
|
|
||||||
foreach (gaseous_server.Models.Game game in hSearch)
|
|
||||||
{
|
|
||||||
hGamesToReturn.Add(game);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hGamesToReturn;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new List<gaseous_server.Models.Game>();
|
return new List<gaseous_server.Models.Game>();
|
||||||
}
|
}
|
||||||
|
@@ -314,7 +314,8 @@ namespace gaseous_server.Controllers
|
|||||||
},
|
},
|
||||||
MetadataSource = new SystemSettingsModel.MetadataSourceItem()
|
MetadataSource = new SystemSettingsModel.MetadataSourceItem()
|
||||||
{
|
{
|
||||||
Source = Config.MetadataConfiguration.MetadataSource,
|
Source = Config.MetadataConfiguration.DefaultMetadataSource,
|
||||||
|
UseHasheousProxy = Config.MetadataConfiguration.MetadataUseHasheousProxy,
|
||||||
IGDBClientId = Config.IGDB.ClientId,
|
IGDBClientId = Config.IGDB.ClientId,
|
||||||
IGDBClientSecret = Config.IGDB.Secret
|
IGDBClientSecret = Config.IGDB.Secret
|
||||||
}
|
}
|
||||||
@@ -340,7 +341,8 @@ namespace gaseous_server.Controllers
|
|||||||
Config.MetadataConfiguration.HasheousHost = model.SignatureSource.HasheousHost;
|
Config.MetadataConfiguration.HasheousHost = model.SignatureSource.HasheousHost;
|
||||||
Config.MetadataConfiguration.HasheousAPIKey = model.SignatureSource.HasheousAPIKey;
|
Config.MetadataConfiguration.HasheousAPIKey = model.SignatureSource.HasheousAPIKey;
|
||||||
Config.MetadataConfiguration.HasheousSubmitFixes = model.SignatureSource.HasheousSubmitFixes;
|
Config.MetadataConfiguration.HasheousSubmitFixes = model.SignatureSource.HasheousSubmitFixes;
|
||||||
Config.MetadataConfiguration.MetadataSource = model.MetadataSource.Source;
|
Config.MetadataConfiguration.DefaultMetadataSource = model.MetadataSource.Source;
|
||||||
|
Config.MetadataConfiguration.MetadataUseHasheousProxy = model.MetadataSource.UseHasheousProxy;
|
||||||
Config.IGDB.ClientId = model.MetadataSource.IGDBClientId;
|
Config.IGDB.ClientId = model.MetadataSource.IGDBClientId;
|
||||||
Config.IGDB.Secret = model.MetadataSource.IGDBClientSecret;
|
Config.IGDB.Secret = model.MetadataSource.IGDBClientSecret;
|
||||||
Config.UpdateConfig();
|
Config.UpdateConfig();
|
||||||
@@ -797,7 +799,8 @@ namespace gaseous_server.Controllers
|
|||||||
|
|
||||||
public class MetadataSourceItem
|
public class MetadataSourceItem
|
||||||
{
|
{
|
||||||
public HasheousClient.Models.MetadataModel.MetadataSources Source { get; set; }
|
public HasheousClient.Models.MetadataSources Source { get; set; }
|
||||||
|
public bool UseHasheousProxy { get; set; }
|
||||||
public string IGDBClientId { get; set; }
|
public string IGDBClientId { get; set; }
|
||||||
public string IGDBClientSecret { get; set; }
|
public string IGDBClientSecret { get; set; }
|
||||||
}
|
}
|
||||||
|
@@ -483,6 +483,8 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
|
SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
Game.Id,
|
Game.Id,
|
||||||
|
Game.MetadataMapId,
|
||||||
|
Game.GameIdType,
|
||||||
Game.`Name`,
|
Game.`Name`,
|
||||||
Game.NameThe,
|
Game.NameThe,
|
||||||
Game.Slug,
|
Game.Slug,
|
||||||
@@ -507,15 +509,11 @@ SELECT DISTINCT
|
|||||||
FROM
|
FROM
|
||||||
(SELECT DISTINCT
|
(SELECT DISTINCT
|
||||||
Game.*,
|
Game.*,
|
||||||
CASE
|
|
||||||
WHEN Game.`Name` LIKE 'The %' THEN CONCAT(TRIM(SUBSTR(Game.`Name` FROM 4)), ', The')
|
|
||||||
ELSE Game.`Name`
|
|
||||||
END AS NameThe,
|
|
||||||
view_Games_Roms.PlatformId,
|
view_Games_Roms.PlatformId,
|
||||||
AgeGroup.AgeGroupId,
|
AgeGroup.AgeGroupId,
|
||||||
COUNT(view_Games_Roms.Id) AS RomCount
|
COUNT(view_Games_Roms.Id) AS RomCount
|
||||||
FROM
|
FROM
|
||||||
Game
|
view_GamesWithRoms AS Game
|
||||||
LEFT JOIN AgeGroup ON Game.Id = AgeGroup.GameId
|
LEFT JOIN AgeGroup ON Game.Id = AgeGroup.GameId
|
||||||
LEFT JOIN view_Games_Roms ON Game.Id = view_Games_Roms.GameId" + platformWhereClause + @"
|
LEFT JOIN view_Games_Roms ON Game.Id = view_Games_Roms.GameId" + platformWhereClause + @"
|
||||||
LEFT JOIN AlternativeName ON Game.Id = AlternativeName.Game " + nameWhereClause + @"
|
LEFT JOIN AlternativeName ON Game.Id = AlternativeName.Game " + nameWhereClause + @"
|
||||||
@@ -553,7 +551,6 @@ FROM
|
|||||||
Favourites ON Game.Id = Favourites.GameId AND Favourites.UserId = @userid " + whereClause + " " + havingClause + " " + orderByClause;
|
Favourites ON Game.Id = Favourites.GameId AND Favourites.UserId = @userid " + whereClause + " " + havingClause + " " + orderByClause;
|
||||||
List<Games.MinimalGameItem> RetVal = new List<Games.MinimalGameItem>();
|
List<Games.MinimalGameItem> RetVal = new List<Games.MinimalGameItem>();
|
||||||
|
|
||||||
Console.WriteLine(sql);
|
|
||||||
DataTable dbResponse = db.ExecuteCMD(sql, whereParams, new Database.DatabaseMemoryCacheOptions(CacheEnabled: true, ExpirationSeconds: 60));
|
DataTable dbResponse = db.ExecuteCMD(sql, whereParams, new Database.DatabaseMemoryCacheOptions(CacheEnabled: true, ExpirationSeconds: 60));
|
||||||
|
|
||||||
// get count
|
// get count
|
||||||
@@ -572,6 +569,9 @@ FROM
|
|||||||
}
|
}
|
||||||
|
|
||||||
Models.Game retGame = Storage.BuildCacheObject<Models.Game>(new Models.Game(), dbResponse.Rows[i]);
|
Models.Game retGame = Storage.BuildCacheObject<Models.Game>(new Models.Game(), dbResponse.Rows[i]);
|
||||||
|
retGame.MetadataMapId = (long)dbResponse.Rows[i]["MetadataMapId"];
|
||||||
|
retGame.MetadataSource = (HasheousClient.Models.MetadataSources)dbResponse.Rows[i]["GameIdType"];
|
||||||
|
|
||||||
Games.MinimalGameItem retMinGame = new Games.MinimalGameItem(retGame);
|
Games.MinimalGameItem retMinGame = new Games.MinimalGameItem(retGame);
|
||||||
retMinGame.Index = i;
|
retMinGame.Index = i;
|
||||||
if (dbResponse.Rows[i]["RomSaveCount"] != DBNull.Value || dbResponse.Rows[i]["MediaGroupSaveCount"] != DBNull.Value)
|
if (dbResponse.Rows[i]["RomSaveCount"] != DBNull.Value || dbResponse.Rows[i]["MediaGroupSaveCount"] != DBNull.Value)
|
||||||
|
@@ -14,7 +14,10 @@ namespace gaseous_server.Models
|
|||||||
public bool HasSavedGame { get; set; } = false;
|
public bool HasSavedGame { get; set; } = false;
|
||||||
|
|
||||||
[NoDatabase]
|
[NoDatabase]
|
||||||
public HasheousClient.Models.MetadataModel.MetadataSources MetadataSource { get; set; }
|
public long MetadataMapId { get; set; }
|
||||||
|
|
||||||
|
[NoDatabase]
|
||||||
|
public HasheousClient.Models.MetadataSources MetadataSource { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class NoDatabaseAttribute : Attribute
|
internal class NoDatabaseAttribute : Attribute
|
||||||
|
19
gaseous-server/Models/MetadataMap.cs
Normal file
19
gaseous-server/Models/MetadataMap.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using HasheousClient.Models;
|
||||||
|
|
||||||
|
namespace gaseous_server.Models
|
||||||
|
{
|
||||||
|
public class MetadataMap
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public long PlatformId { get; set; }
|
||||||
|
public string SignatureGameName { get; set; }
|
||||||
|
public List<MetadataMapItem> MetadataMapItems { get; set; }
|
||||||
|
|
||||||
|
public class MetadataMapItem
|
||||||
|
{
|
||||||
|
public HasheousClient.Models.MetadataSources SourceType { get; set; }
|
||||||
|
public long SourceId { get; set; }
|
||||||
|
public bool Preferred { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -446,8 +446,8 @@ namespace gaseous_server.Models
|
|||||||
{
|
{
|
||||||
if (Signature.Game != null) { Signature.Game.System = PlatformMapping.IGDBName; }
|
if (Signature.Game != null) { Signature.Game.System = PlatformMapping.IGDBName; }
|
||||||
}
|
}
|
||||||
Signature.Flags.IGDBPlatformId = PlatformMapping.IGDBId;
|
Signature.Flags.PlatformId = PlatformMapping.IGDBId;
|
||||||
Signature.Flags.IGDBPlatformName = PlatformMapping.IGDBName;
|
Signature.Flags.PlatformName = PlatformMapping.IGDBName;
|
||||||
|
|
||||||
PlatformFound = true;
|
PlatformFound = true;
|
||||||
|
|
||||||
@@ -470,8 +470,8 @@ namespace gaseous_server.Models
|
|||||||
{
|
{
|
||||||
if (Signature.Game != null) { Signature.Game.System = PlatformMapping.IGDBName; }
|
if (Signature.Game != null) { Signature.Game.System = PlatformMapping.IGDBName; }
|
||||||
}
|
}
|
||||||
Signature.Flags.IGDBPlatformId = PlatformMapping.IGDBId;
|
Signature.Flags.PlatformId = PlatformMapping.IGDBId;
|
||||||
Signature.Flags.IGDBPlatformName = PlatformMapping.IGDBName;
|
Signature.Flags.PlatformName = PlatformMapping.IGDBName;
|
||||||
|
|
||||||
PlatformFound = true;
|
PlatformFound = true;
|
||||||
|
|
||||||
|
@@ -1,14 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
using gaseous_server.Classes;
|
||||||
|
using gaseous_server.Classes.Metadata;
|
||||||
using gaseous_signature_parser.models.RomSignatureObject;
|
using gaseous_signature_parser.models.RomSignatureObject;
|
||||||
|
using HasheousClient.Models;
|
||||||
|
|
||||||
namespace gaseous_server.Models
|
namespace gaseous_server.Models
|
||||||
{
|
{
|
||||||
public class Signatures_Games : HasheousClient.Models.SignatureModel
|
public class Signatures_Games : HasheousClient.Models.SignatureModel
|
||||||
{
|
{
|
||||||
public Signatures_Games()
|
public Signatures_Games()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int Score
|
public int Score
|
||||||
@@ -34,13 +37,97 @@ namespace gaseous_server.Models
|
|||||||
public GameItem Game = new GameItem();
|
public GameItem Game = new GameItem();
|
||||||
public RomItem Rom = new RomItem();
|
public RomItem Rom = new RomItem();
|
||||||
|
|
||||||
public SignatureFlags Flags = new SignatureFlags();
|
public SignatureFlags Flags
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
SignatureFlags _flags = new SignatureFlags();
|
||||||
|
|
||||||
|
foreach (SourceValues.SourceValueItem source in MetadataSources.Platforms)
|
||||||
|
{
|
||||||
|
if (source.Source == Config.MetadataConfiguration.DefaultMetadataSource)
|
||||||
|
{
|
||||||
|
_flags.PlatformId = source.Id;
|
||||||
|
_flags.PlatformName = source.Name;
|
||||||
|
_flags.PlatformMetadataSource = source.Source;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (SourceValues.SourceValueItem source in MetadataSources.Games)
|
||||||
|
{
|
||||||
|
if (source.Source == Config.MetadataConfiguration.DefaultMetadataSource)
|
||||||
|
{
|
||||||
|
_flags.GameId = source.Id;
|
||||||
|
_flags.GameName = source.Name;
|
||||||
|
_flags.GameMetadataSource = source.Source;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _flags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SourceValues MetadataSources = new SourceValues();
|
||||||
|
|
||||||
|
public class SourceValues
|
||||||
|
{
|
||||||
|
public List<SourceValueItem> Platforms = new List<SourceValueItem>();
|
||||||
|
public List<SourceValueItem> Games = new List<SourceValueItem>();
|
||||||
|
|
||||||
|
public class SourceValueItem
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public HasheousClient.Models.MetadataSources Source { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddPlatform(long Id, string Name, HasheousClient.Models.MetadataSources Source)
|
||||||
|
{
|
||||||
|
// check that the platform doesn't already exist
|
||||||
|
foreach (SourceValueItem item in Platforms)
|
||||||
|
{
|
||||||
|
if (item.Id == Id)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceValueItem newItem = new SourceValueItem();
|
||||||
|
newItem.Id = Id;
|
||||||
|
newItem.Name = Name;
|
||||||
|
newItem.Source = Source;
|
||||||
|
Platforms.Add(newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddGame(long Id, string Name, HasheousClient.Models.MetadataSources Source)
|
||||||
|
{
|
||||||
|
// check that the game doesn't already exist
|
||||||
|
foreach (SourceValueItem item in Games)
|
||||||
|
{
|
||||||
|
if (item.Id == Id)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceValueItem newItem = new SourceValueItem();
|
||||||
|
newItem.Id = Id;
|
||||||
|
newItem.Name = Name;
|
||||||
|
newItem.Source = Source;
|
||||||
|
Games.Add(newItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class SignatureFlags
|
public class SignatureFlags
|
||||||
{
|
{
|
||||||
public long IGDBPlatformId { get; set; }
|
public long PlatformId { get; set; }
|
||||||
public string IGDBPlatformName { get; set; }
|
public string PlatformName { get; set; }
|
||||||
public long IGDBGameId { get; set; }
|
public long GameId { get; set; }
|
||||||
|
public string GameName { get; set; }
|
||||||
|
public HasheousClient.Models.MetadataSources PlatformMetadataSource { get; set; }
|
||||||
|
public HasheousClient.Models.MetadataSources GameMetadataSource { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GameItem : HasheousClient.Models.SignatureModel.GameItem
|
public class GameItem : HasheousClient.Models.SignatureModel.GameItem
|
||||||
@@ -211,7 +298,8 @@ namespace gaseous_server.Models
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
switch (inType.ToLower())
|
switch (inType.ToLower())
|
||||||
{
|
{
|
||||||
case "disk":
|
case "disk":
|
||||||
|
@@ -52,7 +52,7 @@ Config.UpdateConfig();
|
|||||||
GameLibrary.UpdateDefaultLibraryPath();
|
GameLibrary.UpdateDefaultLibraryPath();
|
||||||
|
|
||||||
// set api metadata source from config
|
// set api metadata source from config
|
||||||
Communications.MetadataSource = Config.MetadataConfiguration.MetadataSource;
|
Communications.MetadataSource = Config.MetadataConfiguration.DefaultMetadataSource;
|
||||||
|
|
||||||
// set up hasheous client
|
// set up hasheous client
|
||||||
HasheousClient.WebApp.HttpHelper.BaseUri = Config.MetadataConfiguration.HasheousHost;
|
HasheousClient.WebApp.HttpHelper.BaseUri = Config.MetadataConfiguration.HasheousHost;
|
||||||
|
@@ -115,13 +115,16 @@ CREATE INDEX idx_favourites_userid_gameid ON Favourites (UserId, GameId);
|
|||||||
CREATE TABLE `MetadataMap` (
|
CREATE TABLE `MetadataMap` (
|
||||||
`Id` bigint(20) NOT NULL AUTO_INCREMENT,
|
`Id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
`PlatformId` bigint(20) NOT NULL,
|
`PlatformId` bigint(20) NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
`SignatureGameName` varchar(255) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
INDEX `idx_gamename` (
|
||||||
|
`SignatureGameName`,
|
||||||
|
`PlatformId`
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE `MetadataMapBridge` (
|
CREATE TABLE `MetadataMapBridge` (
|
||||||
`ParentMapId` bigint(20) NOT NULL,
|
`ParentMapId` bigint(20) NOT NULL,
|
||||||
`SignatureGameName` varchar(255) NOT NULL,
|
|
||||||
`SignaturePlatformId` bigint(20) NOT NULL,
|
|
||||||
`MetadataSourceType` int(11) NOT NULL DEFAULT 0,
|
`MetadataSourceType` int(11) NOT NULL DEFAULT 0,
|
||||||
`MetadataSourceId` bigint(20) NOT NULL,
|
`MetadataSourceId` bigint(20) NOT NULL,
|
||||||
`Preferred` BOOLEAN NOT NULL DEFAULT 0,
|
`Preferred` BOOLEAN NOT NULL DEFAULT 0,
|
||||||
@@ -131,14 +134,20 @@ CREATE TABLE `MetadataMapBridge` (
|
|||||||
`MetadataSourceType`,
|
`MetadataSourceType`,
|
||||||
`MetadataSourceId`
|
`MetadataSourceId`
|
||||||
),
|
),
|
||||||
INDEX `idx_gamename` (
|
CONSTRAINT `MetadataMapBridge_MetadataMap` FOREIGN KEY (`ParentMapId`) REFERENCES `MetadataMap` (`Id`) ON DELETE CASCADE
|
||||||
`SignatureGameName`,
|
|
||||||
`SignaturePlatformId`
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `view_MetadataMap` AS
|
||||||
|
SELECT `MetadataMap`.*, `MetadataMapBridge`.`MetadataSourceType`, `MetadataMapBridge`.`MetadataSourceId`
|
||||||
|
FROM
|
||||||
|
`MetadataMap`
|
||||||
|
LEFT JOIN `MetadataMapBridge` ON (
|
||||||
|
`MetadataMap`.`Id` = `MetadataMapBridge`.`ParentMapId`
|
||||||
|
AND `MetadataMapBridge`.`Preferred` = 1
|
||||||
|
);
|
||||||
|
|
||||||
ALTER TABLE `Games_Roms`
|
ALTER TABLE `Games_Roms`
|
||||||
ADD CONSTRAINT metadataMapId FOREIGN KEY (`MetadataMapId`) REFERENCES `MetadataMapBridge` (`ParentMapId`) ON DELETE CASCADE;
|
ADD CONSTRAINT metadataMapId FOREIGN KEY (`MetadataMapId`) REFERENCES `MetadataMap` (`Id`) ON DELETE CASCADE;
|
||||||
|
|
||||||
ALTER TABLE `Games_Roms`
|
ALTER TABLE `Games_Roms`
|
||||||
ADD COLUMN `MetadataMapId` BIGINT NOT NULL DEFAULT 0;
|
ADD COLUMN `MetadataMapId` BIGINT NOT NULL DEFAULT 0;
|
||||||
@@ -199,6 +208,7 @@ DROP PRIMARY KEY,
|
|||||||
ADD PRIMARY KEY (`Id`, `SourceId`);
|
ADD PRIMARY KEY (`Id`, `SourceId`);
|
||||||
|
|
||||||
ALTER TABLE `Game`
|
ALTER TABLE `Game`
|
||||||
|
CHANGE `Id` `Id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
ADD COLUMN `SourceId` INT NOT NULL DEFAULT 1 AFTER `Id`,
|
ADD COLUMN `SourceId` INT NOT NULL DEFAULT 1 AFTER `Id`,
|
||||||
DROP INDEX IF EXISTS `Id_UNIQUE`,
|
DROP INDEX IF EXISTS `Id_UNIQUE`,
|
||||||
DROP INDEX IF EXISTS `PRIMARY`,
|
DROP INDEX IF EXISTS `PRIMARY`,
|
||||||
@@ -263,4 +273,142 @@ ADD PRIMARY KEY (`Id`, `SourceId`);
|
|||||||
ALTER TABLE `Theme`
|
ALTER TABLE `Theme`
|
||||||
ADD COLUMN `SourceId` INT NOT NULL DEFAULT 1 AFTER `Id`,
|
ADD COLUMN `SourceId` INT NOT NULL DEFAULT 1 AFTER `Id`,
|
||||||
DROP PRIMARY KEY,
|
DROP PRIMARY KEY,
|
||||||
ADD PRIMARY KEY (`Id`, `SourceId`);
|
ADD PRIMARY KEY (`Id`, `SourceId`);
|
||||||
|
|
||||||
|
ALTER TABLE `ReleaseDate`
|
||||||
|
CHANGE `m` `Month` int(11) DEFAULT NULL,
|
||||||
|
CHANGE `y` `Year` int(11) DEFAULT NULL;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `view_Games_Roms` AS
|
||||||
|
SELECT
|
||||||
|
`Games_Roms`.`Id` AS `Id`,
|
||||||
|
`Games_Roms`.`PlatformId` AS `PlatformId`,
|
||||||
|
`view_MetadataMap`.`Id` AS `MetadataMapId`,
|
||||||
|
`view_MetadataMap`.`MetadataSourceType` AS `GameIdType`,
|
||||||
|
`view_MetadataMap`.`MetadataSourceId` AS `GameId`,
|
||||||
|
`Games_Roms`.`Name` AS `Name`,
|
||||||
|
`Games_Roms`.`Size` AS `Size`,
|
||||||
|
`Games_Roms`.`CRC` AS `CRC`,
|
||||||
|
`Games_Roms`.`MD5` AS `MD5`,
|
||||||
|
`Games_Roms`.`SHA1` AS `SHA1`,
|
||||||
|
`Games_Roms`.`DevelopmentStatus` AS `DevelopmentStatus`,
|
||||||
|
`Games_Roms`.`Flags` AS `Flags`,
|
||||||
|
`Games_Roms`.`Attributes` AS `Attributes`,
|
||||||
|
`Games_Roms`.`RomType` AS `RomType`,
|
||||||
|
`Games_Roms`.`RomTypeMedia` AS `RomTypeMedia`,
|
||||||
|
`Games_Roms`.`MediaLabel` AS `MediaLabel`,
|
||||||
|
`Games_Roms`.`RelativePath` AS `RelativePath`,
|
||||||
|
`Games_Roms`.`MetadataSource` AS `MetadataSource`,
|
||||||
|
`Games_Roms`.`MetadataGameName` AS `MetadataGameName`,
|
||||||
|
`Games_Roms`.`MetadataVersion` AS `MetadataVersion`,
|
||||||
|
`Games_Roms`.`LibraryId` AS `LibraryId`,
|
||||||
|
`Games_Roms`.`LastMatchAttemptDate` AS `LastMatchAttemptDate`,
|
||||||
|
`Games_Roms`.`RomDataVersion` AS `RomDataVersion`,
|
||||||
|
CONCAT(
|
||||||
|
`GameLibraries`.`Path`,
|
||||||
|
'/',
|
||||||
|
`Games_Roms`.`RelativePath`
|
||||||
|
) AS `Path`,
|
||||||
|
`GameLibraries`.`Name` AS `LibraryName`
|
||||||
|
FROM (
|
||||||
|
`Games_Roms`
|
||||||
|
JOIN `GameLibraries` ON (
|
||||||
|
`Games_Roms`.`LibraryId` = `GameLibraries`.`Id`
|
||||||
|
)
|
||||||
|
LEFT JOIN `view_MetadataMap` ON (
|
||||||
|
`Games_Roms`.`MetadataMapId` = `view_MetadataMap`.`Id`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `view_GamesWithRoms` AS
|
||||||
|
SELECT DISTINCT
|
||||||
|
`Games_Roms`.`GameId` AS `ROMGameId`,
|
||||||
|
`view_MetadataMap`.`Id` AS `MetadataMapId`,
|
||||||
|
`view_MetadataMap`.`MetadataSourceType` AS `GameIdType`,
|
||||||
|
CASE
|
||||||
|
WHEN `Game`.`Id` IS NULL THEN 0
|
||||||
|
ELSE `Game`.`Id`
|
||||||
|
END AS `Id`,
|
||||||
|
`Game`.`AgeRatings` AS `AgeRatings`,
|
||||||
|
`Game`.`AggregatedRating` AS `AggregatedRating`,
|
||||||
|
`Game`.`AggregatedRatingCount` AS `AggregatedRatingCount`,
|
||||||
|
`Game`.`AlternativeNames` AS `AlternativeNames`,
|
||||||
|
`Game`.`Artworks` AS `Artworks`,
|
||||||
|
`Game`.`Bundles` AS `Bundles`,
|
||||||
|
`Game`.`Category` AS `Category`,
|
||||||
|
`Game`.`Checksum` AS `Checksum`,
|
||||||
|
`Game`.`Collection` AS `Collection`,
|
||||||
|
`Game`.`Cover` AS `Cover`,
|
||||||
|
`Game`.`CreatedAt` AS `CreatedAt`,
|
||||||
|
`Game`.`Dlcs` AS `Dlcs`,
|
||||||
|
`Game`.`Expansions` AS `Expansions`,
|
||||||
|
`Game`.`ExternalGames` AS `ExternalGames`,
|
||||||
|
`Game`.`FirstReleaseDate` AS `FirstReleaseDate`,
|
||||||
|
`Game`.`Follows` AS `Follows`,
|
||||||
|
`Game`.`Franchise` AS `Franchise`,
|
||||||
|
`Game`.`Franchises` AS `Franchises`,
|
||||||
|
`Game`.`GameEngines` AS `GameEngines`,
|
||||||
|
`Game`.`GameModes` AS `GameModes`,
|
||||||
|
`Game`.`Genres` AS `Genres`,
|
||||||
|
`Game`.`Hypes` AS `Hypes`,
|
||||||
|
`Game`.`InvolvedCompanies` AS `InvolvedCompanies`,
|
||||||
|
`Game`.`Keywords` AS `Keywords`,
|
||||||
|
`Game`.`MultiplayerModes` AS `MultiplayerModes`,
|
||||||
|
CASE
|
||||||
|
WHEN `Game`.`Name` IS NULL THEN `view_MetadataMap`.`SignatureGameName`
|
||||||
|
ELSE `Game`.`Name`
|
||||||
|
END AS `Name`,
|
||||||
|
CASE
|
||||||
|
WHEN `Game`.`Name` IS NULL THEN CASE
|
||||||
|
WHEN `view_MetadataMap`.`SignatureGameName` LIKE 'The %' THEN CONCAT(
|
||||||
|
TRIM(
|
||||||
|
SUBSTR(
|
||||||
|
`view_MetadataMap`.`SignatureGameName`,
|
||||||
|
4
|
||||||
|
)
|
||||||
|
),
|
||||||
|
', The'
|
||||||
|
)
|
||||||
|
ELSE `view_MetadataMap`.`SignatureGameName`
|
||||||
|
END
|
||||||
|
WHEN `Game`.`Name` LIKE 'The %' THEN CONCAT(
|
||||||
|
TRIM(SUBSTR(`Game`.`Name`, 4)),
|
||||||
|
', The'
|
||||||
|
)
|
||||||
|
ELSE `Game`.`Name`
|
||||||
|
END AS `NameThe`,
|
||||||
|
`Game`.`ParentGame` AS `ParentGame`,
|
||||||
|
`Game`.`Platforms` AS `Platforms`,
|
||||||
|
`Game`.`PlayerPerspectives` AS `PlayerPerspectives`,
|
||||||
|
`Game`.`Rating` AS `Rating`,
|
||||||
|
`Game`.`RatingCount` AS `RatingCount`,
|
||||||
|
`Game`.`ReleaseDates` AS `ReleaseDates`,
|
||||||
|
`Game`.`Screenshots` AS `Screenshots`,
|
||||||
|
`Game`.`SimilarGames` AS `SimilarGames`,
|
||||||
|
`Game`.`Slug` AS `Slug`,
|
||||||
|
`Game`.`StandaloneExpansions` AS `StandaloneExpansions`,
|
||||||
|
`Game`.`Status` AS `Status`,
|
||||||
|
`Game`.`StoryLine` AS `StoryLine`,
|
||||||
|
`Game`.`Summary` AS `Summary`,
|
||||||
|
`Game`.`Tags` AS `Tags`,
|
||||||
|
`Game`.`Themes` AS `Themes`,
|
||||||
|
`Game`.`TotalRating` AS `TotalRating`,
|
||||||
|
`Game`.`TotalRatingCount` AS `TotalRatingCount`,
|
||||||
|
`Game`.`UpdatedAt` AS `UpdatedAt`,
|
||||||
|
`Game`.`Url` AS `Url`,
|
||||||
|
`Game`.`VersionParent` AS `VersionParent`,
|
||||||
|
`Game`.`VersionTitle` AS `VersionTitle`,
|
||||||
|
`Game`.`Videos` AS `Videos`,
|
||||||
|
`Game`.`Websites` AS `Websites`,
|
||||||
|
`Game`.`dateAdded` AS `dateAdded`,
|
||||||
|
`Game`.`lastUpdated` AS `lastUpdated`
|
||||||
|
FROM (
|
||||||
|
`Games_Roms`
|
||||||
|
JOIN `view_MetadataMap` ON (
|
||||||
|
`view_MetadataMap`.`Id` = `Games_Roms`.`MetadataMapId`
|
||||||
|
)
|
||||||
|
LEFT JOIN `Game` ON (
|
||||||
|
`Game`.`SourceId` = `view_MetadataMap`.`MetadataSourceType`
|
||||||
|
AND `Game`.`Id` = `view_MetadataMap`.`MetadataSourceId`
|
||||||
|
)
|
||||||
|
);
|
@@ -18,9 +18,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
|
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
|
||||||
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
|
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
|
||||||
<PackageReference Include="gaseous-signature-parser" Version="2.2.1" />
|
<PackageReference Include="gaseous-signature-parser" Version="2.3.0" />
|
||||||
<PackageReference Include="gaseous.IGDB" Version="1.0.2" />
|
<PackageReference Include="gaseous.IGDB" Version="1.0.2" />
|
||||||
<PackageReference Include="hasheous-client" Version="1.1.3" />
|
<PackageReference Include="hasheous-client" Version="1.2.0" />
|
||||||
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.8.0" />
|
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.8.0" />
|
||||||
<PackageReference Include="sharpcompress" Version="0.37.2" />
|
<PackageReference Include="sharpcompress" Version="0.37.2" />
|
||||||
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.2.24" />
|
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.2.24" />
|
||||||
|
@@ -13,6 +13,7 @@ function SetupPage() {
|
|||||||
document.head.appendChild(mappingScript);
|
document.head.appendChild(mappingScript);
|
||||||
|
|
||||||
ajaxCall('/api/v1.1/Games/' + gameId, 'GET', function (result) {
|
ajaxCall('/api/v1.1/Games/' + gameId, 'GET', function (result) {
|
||||||
|
console.log(result);
|
||||||
// populate games page
|
// populate games page
|
||||||
gameData = result;
|
gameData = result;
|
||||||
|
|
||||||
@@ -21,19 +22,19 @@ function SetupPage() {
|
|||||||
gameTitleLabel.innerHTML = result.name;
|
gameTitleLabel.innerHTML = result.name;
|
||||||
|
|
||||||
// get critic rating
|
// get critic rating
|
||||||
if (gameData.totalRating) {
|
if (gameData.total_rating) {
|
||||||
var criticscoreval = document.getElementById('gametitle_criticrating_value');
|
var criticscoreval = document.getElementById('gametitle_criticrating_value');
|
||||||
criticscoreval.innerHTML = Math.floor(gameData.totalRating) + '%';
|
criticscoreval.innerHTML = Math.floor(gameData.total_rating) + '%';
|
||||||
|
|
||||||
if (gameData.totalRatingCount) {
|
if (gameData.total_rating_count) {
|
||||||
var criticscorelabel = document.getElementById('gametitle_criticrating_label');
|
var criticscorelabel = document.getElementById('gametitle_criticrating_label');
|
||||||
criticscorelabel.innerHTML = '<img src="/images/IGDB_logo.svg" style="filter: invert(100%); height: 13px; margin-bottom: -5px;" /><span style="font-size: 10px;"> User Rating<br />' + "based on " + gameData.totalRatingCount + " votes</span>"
|
criticscorelabel.innerHTML = '<img src="/images/IGDB_logo.svg" style="filter: invert(100%); height: 13px; margin-bottom: -5px;" /><span style="font-size: 10px;"> User Rating<br />' + "based on " + gameData.total_rating_count + " votes</span>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get alt name
|
// get alt name
|
||||||
var gameTitleAltLabel = document.getElementById('gametitle_alts');
|
var gameTitleAltLabel = document.getElementById('gametitle_alts');
|
||||||
if (result.alternativeNames) {
|
if (result.alternative_names) {
|
||||||
ajaxCall('/api/v1.1/Games/' + gameId + '/alternativename', 'GET', function (result) {
|
ajaxCall('/api/v1.1/Games/' + gameId + '/alternativename', 'GET', function (result) {
|
||||||
var altNames = '';
|
var altNames = '';
|
||||||
for (var i = 0; i < result.length; i++) {
|
for (var i = 0; i < result.length; i++) {
|
||||||
@@ -103,7 +104,7 @@ function SetupPage() {
|
|||||||
var gamePublisherContent = document.getElementById('gamesummary_publishers_content');
|
var gamePublisherContent = document.getElementById('gamesummary_publishers_content');
|
||||||
var gameDeveloperLoaded = false;
|
var gameDeveloperLoaded = false;
|
||||||
var gamePublisherLoaded = false;
|
var gamePublisherLoaded = false;
|
||||||
if (result.involvedCompanies) {
|
if (result.involved_companies) {
|
||||||
ajaxCall('/api/v1.1/Games/' + gameId + '/companies', 'GET', function (result) {
|
ajaxCall('/api/v1.1/Games/' + gameId + '/companies', 'GET', function (result) {
|
||||||
var lstDevelopers = [];
|
var lstDevelopers = [];
|
||||||
var lstPublishers = [];
|
var lstPublishers = [];
|
||||||
@@ -199,9 +200,9 @@ function SetupPage() {
|
|||||||
// load release date
|
// load release date
|
||||||
var gameSummaryRelease = document.getElementById('gamesummary_firstrelease');
|
var gameSummaryRelease = document.getElementById('gamesummary_firstrelease');
|
||||||
var gameSummaryReleaseContent = document.getElementById('gamesummary_firstrelease_content');
|
var gameSummaryReleaseContent = document.getElementById('gamesummary_firstrelease_content');
|
||||||
if (result.firstReleaseDate) {
|
if (result.first_release_date) {
|
||||||
var firstRelease = document.createElement('span');
|
var firstRelease = document.createElement('span');
|
||||||
firstRelease.innerHTML = moment(result.firstReleaseDate).format('LL') + ' (' + moment(result.firstReleaseDate).fromNow() + ')';
|
firstRelease.innerHTML = moment(result.first_release_date).format('LL') + ' (' + moment(result.first_release_date).fromNow() + ')';
|
||||||
gameSummaryReleaseContent.appendChild(firstRelease);
|
gameSummaryReleaseContent.appendChild(firstRelease);
|
||||||
} else {
|
} else {
|
||||||
gameSummaryRelease.setAttribute('style', 'display: none;');
|
gameSummaryRelease.setAttribute('style', 'display: none;');
|
||||||
@@ -210,7 +211,7 @@ function SetupPage() {
|
|||||||
// load ratings
|
// load ratings
|
||||||
let gameSummaryRatings = document.getElementById('gamesummary_ratings');
|
let gameSummaryRatings = document.getElementById('gamesummary_ratings');
|
||||||
let gameSummaryRatingsContent = document.getElementById('gamesummary_ratings_content');
|
let gameSummaryRatingsContent = document.getElementById('gamesummary_ratings_content');
|
||||||
if (result.ageRatings) {
|
if (result.age_ratings) {
|
||||||
ajaxCall('/api/v1.1/Games/' + gameId + '/agerating', 'GET', function (result) {
|
ajaxCall('/api/v1.1/Games/' + gameId + '/agerating', 'GET', function (result) {
|
||||||
let classTable = document.createElement('table');
|
let classTable = document.createElement('table');
|
||||||
|
|
||||||
@@ -305,7 +306,7 @@ function SetupPage() {
|
|||||||
var gameScreenshots_Gallery = document.getElementById('gamescreenshots_gallery_panel');
|
var gameScreenshots_Gallery = document.getElementById('gamescreenshots_gallery_panel');
|
||||||
var imageIndex = 0;
|
var imageIndex = 0;
|
||||||
if (result.videos) {
|
if (result.videos) {
|
||||||
imageIndex = result.videos.ids.length;
|
imageIndex = result.videos.length;
|
||||||
}
|
}
|
||||||
if (result.screenshots) {
|
if (result.screenshots) {
|
||||||
ajaxCall('/api/v1.1/Games/' + gameId + '/screenshots', 'GET', function (screenshotsItem) {
|
ajaxCall('/api/v1.1/Games/' + gameId + '/screenshots', 'GET', function (screenshotsItem) {
|
||||||
@@ -335,10 +336,10 @@ function SetupPage() {
|
|||||||
var vScreenshotItem = document.createElement('li');
|
var vScreenshotItem = document.createElement('li');
|
||||||
vScreenshotItem.id = 'gamescreenshots_gallery_' + i;
|
vScreenshotItem.id = 'gamescreenshots_gallery_' + i;
|
||||||
vScreenshotItem.setAttribute('name', 'gamescreenshots_gallery_item');
|
vScreenshotItem.setAttribute('name', 'gamescreenshots_gallery_item');
|
||||||
vScreenshotItem.setAttribute('style', 'background-image: url("https://i.ytimg.com/vi/' + result[i].videoId + '/hqdefault.jpg"); background-position: center; background-repeat: no-repeat; background-size: contain;)');
|
vScreenshotItem.setAttribute('style', 'background-image: url("https://i.ytimg.com/vi/' + result[i].video_id + '/hqdefault.jpg"); background-position: center; background-repeat: no-repeat; background-size: contain;)');
|
||||||
vScreenshotItem.setAttribute('imageid', i);
|
vScreenshotItem.setAttribute('imageid', i);
|
||||||
vScreenshotItem.setAttribute('imagetype', 1);
|
vScreenshotItem.setAttribute('imagetype', 1);
|
||||||
vScreenshotItem.setAttribute('imageref', result[i].videoId);
|
vScreenshotItem.setAttribute('imageref', result[i].video_id);
|
||||||
vScreenshotItem.className = 'gamescreenshots_gallery_item';
|
vScreenshotItem.className = 'gamescreenshots_gallery_item';
|
||||||
vScreenshotItem.setAttribute('onclick', 'selectScreenshot(' + i + ');');
|
vScreenshotItem.setAttribute('onclick', 'selectScreenshot(' + i + ');');
|
||||||
|
|
||||||
@@ -1448,7 +1449,7 @@ class RomManagement {
|
|||||||
id: data[i].id,
|
id: data[i].id,
|
||||||
text: data[i].name,
|
text: data[i].name,
|
||||||
cover: data[i].cover,
|
cover: data[i].cover,
|
||||||
releaseDate: data[i].firstReleaseDate
|
releaseDate: data[i].first_release_date
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1466,8 +1467,8 @@ function loadArtwork(game, cover) {
|
|||||||
|
|
||||||
// default background should be the artworks
|
// default background should be the artworks
|
||||||
if (game.artworks) {
|
if (game.artworks) {
|
||||||
for (let i = 0; i < game.artworks.ids.length; i++) {
|
for (let i = 0; i < game.artworks.length; i++) {
|
||||||
URLList.push("/api/v1.1/Games/" + gameId + "/artwork/" + game.artworks.ids[i] + "/image/original/" + game.artworks.ids[i] + ".jpg");
|
URLList.push("/api/v1.1/Games/" + gameId + "/artwork/" + game.artworks[i] + "/image/original/" + game.artworks[i] + ".jpg");
|
||||||
}
|
}
|
||||||
} else if (game.cover) {
|
} else if (game.cover) {
|
||||||
// backup background is the cover artwork
|
// backup background is the cover artwork
|
||||||
|
@@ -60,6 +60,7 @@ var pageReloadInterval;
|
|||||||
var firstLoad = true;
|
var firstLoad = true;
|
||||||
|
|
||||||
function formatGamesPanel(targetElement, result, pageNumber, pageSize, forceScrollTop) {
|
function formatGamesPanel(targetElement, result, pageNumber, pageSize, forceScrollTop) {
|
||||||
|
console.log(result);
|
||||||
// set page mode buttons
|
// set page mode buttons
|
||||||
let pageViewButton = document.getElementById('games_library_button_pagedview');
|
let pageViewButton = document.getElementById('games_library_button_pagedview');
|
||||||
let infiniteViewButton = document.getElementById('games_library_button_infiniteview');
|
let infiniteViewButton = document.getElementById('games_library_button_infiniteview');
|
||||||
@@ -434,7 +435,7 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
|
|||||||
}
|
}
|
||||||
// gameImage.src = '/images/unknowngame.png';
|
// gameImage.src = '/images/unknowngame.png';
|
||||||
if (gameObject.cover) {
|
if (gameObject.cover) {
|
||||||
gameImage.setAttribute('data-src', '/api/v1.1/Games/' + gameObject.id + '/cover/' + gameObject.cover.id + '/image/cover_big/' + gameObject.cover.id + '.jpg');
|
gameImage.setAttribute('data-src', '/api/v1.1/Games/' + gameObject.id + '/cover/' + gameObject.cover + '/image/cover_big/' + gameObject.cover + '.jpg');
|
||||||
} else {
|
} else {
|
||||||
gameImage.classList.add(...classes['game_tile_image unknown']);
|
gameImage.classList.add(...classes['game_tile_image unknown']);
|
||||||
gameImage.setAttribute('data-src', '/images/unknowngame.png');
|
gameImage.setAttribute('data-src', '/images/unknowngame.png');
|
||||||
|
Reference in New Issue
Block a user