This commit is contained in:
Michael Green
2024-12-27 16:35:32 +11:00
parent ae41fae54f
commit c170d98a68
9 changed files with 73 additions and 50 deletions

View File

@@ -1298,7 +1298,7 @@ namespace gaseous_server.Classes.Metadata
Platform? platform = Platforms.GetPlatform(Id);
if (platform != null)
{
platform.PlatformLogo = platformLogo.Id;
platform.PlatformLogo = (long)platformLogo.Id;
Storage.NewCacheValue<Platform>(HasheousClient.Models.MetadataSources.None, platform, true);
}
}

View File

@@ -454,7 +454,7 @@ ORDER BY Platform.`Name`;";
public bool IsFavourite { get; set; } = false;
public DateTimeOffset? FirstReleaseDate { get; set; }
public object Cover { get; set; }
public List<object> Artworks { get; set; }
public List<long> Artworks { get; set; }
public List<object> AgeRatings { get; set; }
}
}

View File

@@ -18,14 +18,30 @@ namespace gaseous_server.Classes.Metadata
{
if ((Id == 0) || (Id == null))
{
return null;
Platform returnValue = new Platform();
if (Storage.GetCacheStatus(Communications.MetadataSource, "Platform", 0) == Storage.CacheStatus.NotPresent)
{
returnValue = new Platform
{
Id = 0,
Name = "Unknown Platform",
Slug = "Unknown"
};
Storage.NewCacheValue(Communications.MetadataSource, returnValue);
return returnValue;
}
else
{
return Storage.GetCacheValue<Platform>(Communications.MetadataSource, returnValue, "id", 0);
}
}
else
{
Platform? RetVal = new Platform();
if (Config.MetadataConfiguration.DefaultMetadataSource == HasheousClient.Models.MetadataSources.None)
{
RetVal = (Platform?)Storage.GetCacheValue<Platform>(HasheousClient.Models.MetadataSources.None, RetVal, "Id", (long)Id);
}
else

View File

@@ -334,7 +334,7 @@ namespace gaseous_server.Classes
else
{
// when run normally, update all games (since this will honour cache timeouts)
sql = "SELECT Id, `Name` FROM Game;";
sql = "SELECT MetadataSourceId AS `Id`, MetadataSourceType AS `GameIdType`, SignatureGameName AS `Name` FROM gaseous.view_MetadataMap;";
}
dt = db.ExecuteCMD(sql);
@@ -345,8 +345,8 @@ namespace gaseous_server.Classes
try
{
MetadataSources metadataSource = MetadataSources.IGDB;
Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for game " + dr["name"] + " (" + dr["id"] + ")");
MetadataSources metadataSource = (MetadataSources)Enum.Parse(typeof(MetadataSources), dr["GameIdType"].ToString());
Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for game " + dr["name"] + " (" + dr["id"] + ") using source " + metadataSource.ToString());
HasheousClient.Models.Metadata.IGDB.Game game = Metadata.Games.GetGame(metadataSource, (long)dr["id"]);
// get supporting metadata

View File

@@ -77,44 +77,45 @@ namespace gaseous_server.Controllers
}
}
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{PlatformId}/platformlogo")]
[ProducesResponseType(typeof(PlatformLogo), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult PlatformLogo(long PlatformId)
{
try
{
Platform platformObject = Classes.Metadata.Platforms.GetPlatform(PlatformId);
if (platformObject != null)
{
PlatformLogo logoObjectParent = (PlatformLogo)platformObject.PlatformLogo;
PlatformLogo logoObject = PlatformLogos.GetPlatformLogo(logoObjectParent.Id);
if (logoObject != null)
{
return Ok(logoObject);
}
else
{
return NotFound();
}
}
else
{
return NotFound();
}
}
catch
{
return NotFound();
}
}
// [MapToApiVersion("1.0")]
// [MapToApiVersion("1.1")]
// [HttpGet]
// [Route("{PlatformId}/platformlogo")]
// [ProducesResponseType(typeof(PlatformLogo), StatusCodes.Status200OK)]
// [ProducesResponseType(StatusCodes.Status404NotFound)]
// public ActionResult PlatformLogo(long PlatformId)
// {
// try
// {
// Platform platformObject = Classes.Metadata.Platforms.GetPlatform(PlatformId);
// if (platformObject != null)
// {
// PlatformLogo logoObjectParent = (PlatformLogo)platformObject.PlatformLogo;
// PlatformLogo logoObject = PlatformLogos.GetPlatformLogo(logoObjectParent.Id);
// if (logoObject != null)
// {
// return Ok(logoObject);
// }
// else
// {
// return NotFound();
// }
// }
// else
// {
// return NotFound();
// }
// }
// catch
// {
// return NotFound();
// }
// }
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{PlatformId}/platformlogo/{size}/")]
[Route("{PlatformId}/platformlogo/{size}/logo.png")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
@@ -124,12 +125,10 @@ namespace gaseous_server.Controllers
{
Platform platformObject = Classes.Metadata.Platforms.GetPlatform(PlatformId);
PlatformLogo? logoObject = null;
try
{
logoObject = PlatformLogos.GetPlatformLogo((long)platformObject.PlatformLogo, Communications.MetadataSource);
}
catch
logoObject = PlatformLogos.GetPlatformLogo((long)platformObject.PlatformLogo, Communications.MetadataSource);
if (logoObject == null)
{
// getting the logo failed, so we'll try a platform variant if available
if (platformObject.Versions != null)

View File

@@ -20,7 +20,7 @@
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="gaseous-signature-parser" Version="2.3.0" />
<PackageReference Include="gaseous.IGDB" Version="1.0.2" />
<PackageReference Include="hasheous-client" Version="1.2.2" />
<PackageReference Include="hasheous-client" Version="1.2.3" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.8.0" />
<PackageReference Include="sharpcompress" Version="0.37.2" />
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.2.24" />

View File

@@ -411,7 +411,7 @@ function LoadGamePlatforms() {
let platformContainer = document.getElementById('gamesummaryplatformscontent');
platformContainer.innerHTML = '';
for (let i = 0; i < result.length; i++) {
let logoUrl = '/api/v1.1/Platforms/' + result[i].id + '/platformlogo/original/logo.png';
let logoUrl = '/api/v1.1/Platforms/' + result[i].id + '/platformlogo/original/';
// create platform container
let platformItem = document.createElement('div');

View File

@@ -28,12 +28,17 @@ function loadPlatformMapping(Overwrite) {
);
for (let i = 0; i < result.length; i++) {
let logoBox = document.createElement('div');
logoBox.classList.add('platform_image_container');
let logo = document.createElement('img');
logo.src = '/api/v1.1/Platforms/' + result[i].igdbId + '/platformlogo/original/logo.png';
logo.src = '/api/v1.1/Platforms/' + result[i].igdbId + '/platformlogo/original/';
logo.alt = result[i].igdbName;
logo.title = result[i].igdbName;
logo.classList.add('platform_image');
logoBox.appendChild(logo);
let hasWebEmulator = '';
if (result[i].webEmulator.type.length > 0) {
hasWebEmulator = 'Yes';
@@ -56,7 +61,7 @@ function loadPlatformMapping(Overwrite) {
}
let newRow = [
logo,
logoBox,
result[i].igdbName,
result[i].extensions.supportedFileExtensions.join(', '),
result[i].extensions.uniqueFileExtensions.join(', '),

View File

@@ -2958,6 +2958,8 @@ button:not(.select2-selection__choice__remove):not(.select2-selection__clear):no
justify-content: center;
align-items: center;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 20px;
padding-right: 20px;
background-color: white;
@@ -2965,6 +2967,7 @@ button:not(.select2-selection__choice__remove):not(.select2-selection__clear):no
.platform_image {
width: 70px;
max-height: 70px;
}
.platform_name_container {