Skip to content

Commit 4050b4e

Browse files
authored
Merge pull request #298 from TeamWheelWizard/fix/gamebanana
fix(gamebanana): Filter out mod results with content ratings
2 parents 8b77e09 + e532030 commit 4050b4e

7 files changed

Lines changed: 19 additions & 9 deletions

File tree

WheelWizard.Test/Features/GameBananaTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ private GameBananaModPreview CreateFakeModPreview(int id)
212212
},
213213
ModelName = "Mod",
214214
PreviewMedia = new(),
215+
HasContentRatings = false,
215216
};
216217
}
217218

WheelWizard/Features/GameBanana/Domain/GameBananaModDetails.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,8 @@ public class GameBananaModDetails
6363
public required int DownloadCount { get; set; }
6464

6565
[JsonPropertyName("_aFiles")]
66-
public required List<GameBananaModFiles> Files { get; set; }
66+
public List<GameBananaModFiles>? Files { get; set; }
67+
68+
[JsonPropertyName("_aArchivedFiles")]
69+
public List<GameBananaModFiles>? ArchivedFiles { get; set; }
6770
}

WheelWizard/Features/GameBanana/Domain/GameBananaModPreview.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public class GameBananaModPreview
2525
[JsonPropertyName("_aPreviewMedia")]
2626
public required GameBananaPreviewMedia PreviewMedia { get; set; }
2727

28+
[JsonPropertyName("_bHasContentRatings")]
29+
public required bool HasContentRatings { get; set; }
30+
2831
[JsonPropertyName("_nLikeCount")]
2932
public int LikeCount { get; set; }
3033

WheelWizard/Features/GameBanana/GameBananaSingletonService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public GameBananaModPreview GetLoadingPreview()
7070
AvatarUrl = "",
7171
},
7272
PreviewMedia = new(),
73+
HasContentRatings = false,
7374
};
7475
}
7576
}

WheelWizard/Services/Endpoints.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class Endpoints
1515
/// <summary>
1616
/// The base address for accessing the GameBanana API
1717
/// </summary>
18-
public const string GameBananaBaseAddress = "https://gamebanana.com/apiv11";
18+
public const string GameBananaBaseAddress = "https://gamebanana.com/apiv12";
1919

2020
/// <summary>
2121
/// The address for the GitHub API
@@ -48,7 +48,4 @@ public static class Endpoints
4848

4949
// Other
5050
public const string MiiChannelWAD = "-";
51-
52-
//GameBanana
53-
public const string GameBananaBaseUrl = "https://gamebanana.com/apiv11";
5451
}

WheelWizard/Views/Popups/ModManagement/ModBrowserWindow.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private async Task LoadMods(int page, string searchTerm = "", bool ensurePatchRe
8787
}
8888

8989
var metadata = result.Value.MetaData;
90-
var newMods = result.Value.Records.Where(mod => mod.ModelName == "Mod").ToList();
90+
var newMods = result.Value.Records.Where(mod => mod.ModelName == "Mod" && !mod.HasContentRatings).ToList();
9191

9292
foreach (var mod in newMods)
9393
{

WheelWizard/Views/Popups/ModManagement/ModContent.axaml.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Avalonia.Interactivity;
1+
using Avalonia.Interactivity;
22
using Avalonia.Media.Imaging;
33
using WheelWizard.GameBanana;
44
using WheelWizard.GameBanana.Domain;
@@ -216,8 +216,13 @@ private async Task<OperationResult> DownloadAndInstallCurrentModAsync()
216216
if (prepareResult.IsFailure)
217217
return prepareResult.Error;
218218

219-
var downloadUrls = OverrideDownloadUrl != null ? [OverrideDownloadUrl] : CurrentMod.Files.Select(f => f.DownloadUrl).ToList();
220-
if (!downloadUrls.Any())
219+
var downloadUrls =
220+
OverrideDownloadUrl != null
221+
? [OverrideDownloadUrl]
222+
: CurrentMod.Files?.Select(f => f.DownloadUrl).ToList()
223+
?? CurrentMod.ArchivedFiles?.Select(f => f.DownloadUrl).ToList()
224+
?? [];
225+
if (downloadUrls.Count == 0)
221226
return Fail("No downloadable files were found for this mod.");
222227

223228
var progressWindow = new ProgressWindow(t("progress.downloading_mod", CurrentMod.Name)!);

0 commit comments

Comments
 (0)