Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for beatsaber 1.29.0 + download fixes #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal static void RemoveHarmonyPatches()
{
if (instance != null && IsPatched)
{
instance.UnpatchAll(InstanceId);
Harmony.UnpatchID(InstanceId);
IsPatched = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions ModelDownloader/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void Init(IPALogger logger, Config config, Zenjector zenjector)
Instance = this;
Log = logger;
Log.Info("ModelDownloader initialized.");
zenjector.OnApp<ModelDownloaderCoreInstaller>().WithParameters(config.Generated<PluginConfig>());
zenjector.OnMenu<ModelDownloaderMenuInstaller>();
zenjector.Install<ModelDownloaderCoreInstaller>(Location.App, config.Generated<PluginConfig>());
zenjector.Install<ModelDownloaderMenuInstaller>(Location.Menu);
}

[OnStart]
Expand Down
6 changes: 3 additions & 3 deletions ModelDownloader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModelDownloader")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -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")]
3 changes: 3 additions & 0 deletions ModelDownloader/Utils/DownloadUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion ModelDownloader/Utils/ModelsaberUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ public static async Task<byte[]> 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();
Expand Down
10 changes: 5 additions & 5 deletions ModelDownloader/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}