diff --git a/ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs b/ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs index 8eda94a..2f93e9d 100644 --- a/ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs +++ b/ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs @@ -31,7 +31,7 @@ internal static void RemoveHarmonyPatches() { if (instance != null && IsPatched) { - instance.UnpatchAll(InstanceId); + Harmony.UnpatchID(InstanceId); IsPatched = false; } } diff --git a/ModelDownloader/Plugin.cs b/ModelDownloader/Plugin.cs index a35345b..8862904 100644 --- a/ModelDownloader/Plugin.cs +++ b/ModelDownloader/Plugin.cs @@ -27,8 +27,8 @@ public void Init(IPALogger logger, Config config, Zenjector zenjector) Instance = this; Log = logger; Log.Info("ModelDownloader initialized."); - zenjector.OnApp().WithParameters(config.Generated()); - zenjector.OnMenu(); + zenjector.Install(Location.App, config.Generated()); + zenjector.Install(Location.Menu); } [OnStart] diff --git a/ModelDownloader/Properties/AssemblyInfo.cs b/ModelDownloader/Properties/AssemblyInfo.cs index 3418c7b..2a674bb 100644 --- a/ModelDownloader/Properties/AssemblyInfo.cs +++ b/ModelDownloader/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ModelDownloader")] -[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.6")] +[assembly: AssemblyFileVersion("1.1.6")] diff --git a/ModelDownloader/Utils/DownloadUtils.cs b/ModelDownloader/Utils/DownloadUtils.cs index 3101193..9cde6f6 100644 --- a/ModelDownloader/Utils/DownloadUtils.cs +++ b/ModelDownloader/Utils/DownloadUtils.cs @@ -66,6 +66,9 @@ public static async void DownloadModel(ModelsaberEntry model, string DownloadPat byte[] fileBytes = await ModelsaberUtils.GetModelBytes(model); string modelFileName = model.Download.Substring(model.Download.LastIndexOf("/") + 1); + // Remove illegal characters from the filename + modelFileName = new string(modelFileName.Where(c => !Path.GetInvalidFileNameChars().Contains(c)).ToArray()); + Plugin.Log.Info("Checking hash..."); if (model.Hash.ToLower() == MD5Checksum(fileBytes).ToLower()) Plugin.Log.Info($"Hash check for {model.Name} passed!"); else diff --git a/ModelDownloader/Utils/ModelsaberUtils.cs b/ModelDownloader/Utils/ModelsaberUtils.cs index 77029e9..bc4d203 100644 --- a/ModelDownloader/Utils/ModelsaberUtils.cs +++ b/ModelDownloader/Utils/ModelsaberUtils.cs @@ -103,7 +103,12 @@ public static async Task GetModelBytes(ModelsaberEntry entry) if (!Uri.TryCreate(entry.Download, UriKind.Absolute, out downloadURL)) { downloadURL = new Uri(entry.Download.Substring(0, entry.Download.LastIndexOf("/")) + "/" + entry.Download); - } + } + //encode URL + int index = downloadURL.ToString().LastIndexOf('/'); + string basePart = downloadURL.ToString().Substring(0, index + 1); + string encodedPart = Uri.EscapeDataString(downloadURL.ToString().Substring(index + 1)); + downloadURL = new Uri(basePart + encodedPart); client.BaseAddress = null; HttpResponseMessage response = await client.GetAsync(downloadURL); byte[] modelBytes = await response.Content.ReadAsByteArrayAsync(); diff --git a/ModelDownloader/manifest.json b/ModelDownloader/manifest.json index 3059f3d..93b969f 100644 --- a/ModelDownloader/manifest.json +++ b/ModelDownloader/manifest.json @@ -3,13 +3,13 @@ "id": "ModelDownloader", "name": "ModelDownloader", "author": "Bobbie", - "version": "1.1.2", + "version": "1.1.6", "description": "A PC Beat Saber mod that allows you to download Sabers, Notes, Platforms, and Avatars directly from ModelSaber, all from a convenient window within your game.", - "gameVersion": "1.15.0", + "gameVersion": "1.29.0", "dependsOn": { - "BSIPA": "^4.0.5", - "BeatSaberMarkupLanguage": "^1.3.5", - "SiraUtil": "^2.2.0" + "BSIPA": "^4.2.2", + "BeatSaberMarkupLanguage": "^1.6.10", + "SiraUtil": "^3.1.2" }, "features": [] } \ No newline at end of file