From 1b846ec8c3282dd4d99b37f70bc21ed6f95a3274 Mon Sep 17 00:00:00 2001 From: Jacob Morrison Date: Wed, 14 Aug 2024 13:26:00 -0400 Subject: [PATCH] - Add support for new Sunshine app properties (#24) - Fix cover images not showing up in clients - Clean game name from common suffixes being appended to PC editions - Update to .NET 8 --- SunshineGameFinder/ImageScraper.cs | 9 ++------- SunshineGameFinder/Program.cs | 15 +++++++++++++-- SunshineGameFinder/SunshineAppsConfig.cs | 11 +++++++++++ SunshineGameFinder/SunshineGameFinder.csproj | 8 ++++---- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/SunshineGameFinder/ImageScraper.cs b/SunshineGameFinder/ImageScraper.cs index 5532abb..9436b84 100644 --- a/SunshineGameFinder/ImageScraper.cs +++ b/SunshineGameFinder/ImageScraper.cs @@ -1,10 +1,4 @@ using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SunshineGameFinder { @@ -154,10 +148,11 @@ public static async Task SaveIGDBImageToCoversFolder(string gameName, st int gameId = await GetIDForGame(gameName); var rawJson = await (await HttpClient.GetAsync(gameTemplate.Replace("@ID", gameId.ToString()))).Content.ReadAsStringAsync(); var game = JsonConvert.DeserializeObject(rawJson); + if (game == null) return null; var coverUrl = game.cover.url; var stream = await (await HttpClient.GetAsync("https:" + coverUrl.Replace("thumb", "cover_big"))).Content.ReadAsStreamAsync(); - string fullpath = coversFolderPath + gameId.ToString() + ".jpg"; + string fullpath = coversFolderPath + gameId.ToString() + ".png"; using FileStream fs = new(fullpath, FileMode.OpenOrCreate); stream.Position = 0; await stream.CopyToAsync(fs); diff --git a/SunshineGameFinder/Program.cs b/SunshineGameFinder/Program.cs index 09045d7..e3c9505 100644 --- a/SunshineGameFinder/Program.cs +++ b/SunshineGameFinder/Program.cs @@ -111,7 +111,7 @@ void ScanFolder(string folder) foreach (var gameDir in di.GetDirectories()) { Logger.Log($"Looking for game exe in {gameDir}..."); - var gameName = gameDir.Name; + var gameName = CleanGameName(gameDir.Name); if (exclusionWords.Any(ew => gameName.Contains(ew))) { Logger.Log($"Skipping {gameName} as it was an excluded word match..."); @@ -152,7 +152,7 @@ void ScanFolder(string folder) workingdir = "" }; } - string coversFolderPath = sunshineRootFolder + "/covers/"; + string coversFolderPath = Path.GetFullPath(sunshineRootFolder.Replace("\\", "/") + "/covers/"); string fullPathOfCoverImage = ImageScraper.SaveIGDBImageToCoversFolder(gameName, coversFolderPath).Result; if (!string.IsNullOrEmpty(fullPathOfCoverImage)) { @@ -222,4 +222,15 @@ void ScanFolder(string folder) } }, addlDirectoriesOption, addlExeExclusionWords, sunshineConfigLocationOption, forceOption, removeUninstalledOption); + +string CleanGameName(string name) +{ + string[] toReplace = new string[] { "Win10", "Windows 10", "Win11", "Windows 11" }; + foreach (string toRemove in toReplace) + { + name = name.Replace(toRemove, ""); + } + return name.Trim(); +} + rootCommand.Invoke(args); \ No newline at end of file diff --git a/SunshineGameFinder/SunshineAppsConfig.cs b/SunshineGameFinder/SunshineAppsConfig.cs index dd3ba12..c4eadb0 100644 --- a/SunshineGameFinder/SunshineAppsConfig.cs +++ b/SunshineGameFinder/SunshineAppsConfig.cs @@ -19,6 +19,17 @@ public class SunshineApp [JsonProperty("working-dir")] public string workingdir { get; set; } + + [JsonProperty("exclude-global-prep-cmd")] + public bool excludeglobalprepcmd { get; set; } + public bool elevated { get; set; } + [JsonProperty("auto-detach")] + public bool autodetach { get; set; } + [JsonProperty("wait-all")] + public bool waitall { get; set; } + + [JsonProperty("exit-timeout")] + public int exittimeout { get; set; } = 5; } public class Env diff --git a/SunshineGameFinder/SunshineGameFinder.csproj b/SunshineGameFinder/SunshineGameFinder.csproj index d8c1ebd..391b704 100644 --- a/SunshineGameFinder/SunshineGameFinder.csproj +++ b/SunshineGameFinder/SunshineGameFinder.csproj @@ -1,9 +1,9 @@ - + true Exe - net6.0 + net8.0 enable enable Sunshine Game Finder @@ -13,8 +13,8 @@ https://github.com/JMTK/SunshineGameFinder False False - 1.6.0 - 1.6.0 + 1.7.0 + 1.7.0