Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JMTK committed Aug 14, 2024
2 parents 8e6f82c + 1b846ec commit 9be248d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
9 changes: 2 additions & 7 deletions SunshineGameFinder/ImageScraper.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -154,10 +148,11 @@ public static async Task<string> 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<Game>(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);
Expand Down
15 changes: 13 additions & 2 deletions SunshineGameFinder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
11 changes: 11 additions & 0 deletions SunshineGameFinder/SunshineAppsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions SunshineGameFinder/SunshineGameFinder.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PublishTrimmed>true</PublishTrimmed>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Title>Sunshine Game Finder</Title>
Expand All @@ -13,8 +13,8 @@
<RepositoryUrl>https://github.com/JMTK/SunshineGameFinder</RepositoryUrl>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<SignAssembly>False</SignAssembly>
<AssemblyVersion>1.6.0</AssemblyVersion>
<FileVersion>1.6.0</FileVersion>
<AssemblyVersion>1.7.0</AssemblyVersion>
<FileVersion>1.7.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 9be248d

Please sign in to comment.