Skip to content

Commit d39bb28

Browse files
committed
Fix some Steam Games not showing up
1 parent edf0b3e commit d39bb28

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Helpers/SteamHelper.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ public static async Task LoadGames()
173173

174174
// get metadata
175175
var gameData = JsonDocument.Parse(await httpClient.GetStringAsync($"https://store.steampowered.com/api/appdetails?appids={gameId}&l=english", _)).RootElement.GetProperty(gameId);
176-
177176
// get playtime data
178177
//var playTimeData = XDocument.Parse(await httpClient.GetStringAsync($"https://steamcommunity.com/profiles/{GetSteam64ID()}/?tab=all&xml=1", _));
179178

@@ -197,17 +196,18 @@ public static async Task LoadGames()
197196
string rating = null;
198197
string descriptors = null;
199198

200-
if (gameData.GetProperty("data").GetProperty("ratings").TryGetProperty(ratingKey.ToLowerInvariant(), out JsonElement ratingData))
199+
var data = gameData.GetProperty("data");
200+
201+
if (data.TryGetProperty("ratings", out var ratings) && ratings.ValueKind == JsonValueKind.Object && ratings.TryGetProperty(ratingKey.ToLowerInvariant(), out var ratingData))
201202
{
202-
if (ratingData.TryGetProperty("rating", out JsonElement ratingElement) && ratingElement.ValueKind == JsonValueKind.String)
203+
if (ratingData.TryGetProperty("rating", out var ratingElement) && ratingElement.ValueKind == JsonValueKind.String)
203204
{
204205
rating = ratingElement.GetString();
205206
}
206207

207-
if (ratingData.TryGetProperty("descriptors", out JsonElement descElement) && descElement.ValueKind == JsonValueKind.String)
208+
if (ratingData.TryGetProperty("descriptors", out var descElement) && descElement.ValueKind == JsonValueKind.String)
208209
{
209-
descriptors = descElement
210-
.GetString()?
210+
descriptors = descElement.GetString()?
211211
.Replace("\r\n", ", ")
212212
.Replace("\n", ", ")
213213
.Replace("\r", ", ");
@@ -250,10 +250,11 @@ public static async Task LoadGames()
250250
AgeRatingTitle = !string.IsNullOrEmpty(rating) ? (ratingTitles.TryGetValue(rating.ToLowerInvariant(), out var title) ? title : rating) : null,
251251
AgeRatingDescription = !string.IsNullOrEmpty(descriptors) ? descriptors : null,
252252
Description = gameData.GetProperty("data").GetProperty("short_description").GetString(),
253-
Screenshots = [.. gameData.GetProperty("data").GetProperty("screenshots")
254-
.EnumerateArray()
255-
.Select(s => s.GetProperty("path_thumbnail").GetString())
256-
.Where(s => !string.IsNullOrWhiteSpace(s))],
253+
Screenshots = gameData.GetProperty("data").TryGetProperty("screenshots", out var screenshots)
254+
? [.. screenshots.EnumerateArray()
255+
.Select(s => s.GetProperty("path_thumbnail").GetString())
256+
.Where(s => !string.IsNullOrWhiteSpace(s))]
257+
: [],
257258
InstallLocation = Path.Combine(steamAppsDir, "common", appManifestData["installdir"]?.ToString()),
258259
ReleaseDate = releaseDate.ToString("d"),
259260
Size = sizeBytes >= 1024 * 1024 * 1024

0 commit comments

Comments
 (0)