diff --git a/Wabbajack.Common/Consts.cs b/Wabbajack.Common/Consts.cs index c8119fd9..dcda85bb 100644 --- a/Wabbajack.Common/Consts.cs +++ b/Wabbajack.Common/Consts.cs @@ -19,9 +19,11 @@ namespace Wabbajack.Common get { var platformType = Environment.Is64BitOperatingSystem ? "x64" : "x86"; - var headerString = $"Wabbajack/{Assembly.GetEntryAssembly().GetName().Version} ({Environment.OSVersion.VersionString}; {platformType}) {RuntimeInformation.FrameworkDescription}"; + var headerString = $"{AppName}/{Assembly.GetEntryAssembly().GetName().Version} ({Environment.OSVersion.VersionString}; {platformType}) {RuntimeInformation.FrameworkDescription}"; return headerString; } } + + public static String AppName = "Automaton"; } } diff --git a/Wabbajack/Compiler.cs b/Wabbajack/Compiler.cs index 37123fe7..61a58784 100644 --- a/Wabbajack/Compiler.cs +++ b/Wabbajack/Compiler.cs @@ -9,6 +9,7 @@ using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using System.Web; using Wabbajack.Common; namespace Wabbajack @@ -290,6 +291,30 @@ namespace Wabbajack ModID = general.modID }; } + else if (general.directURL != null && general.directURL.StartsWith("https://www.dropbox.com/")) + { + var uri = new UriBuilder((string)general.directURL); + var query = HttpUtility.ParseQueryString(uri.Query); + + if (query.GetValues("dl").Count() > 0) + query.Remove("dl"); + + query.Set("dl", "1"); + + uri.Query = query.ToString(); + + result = new DirectURLArchive() + { + URL = uri.ToString() + }; + } + else if (general.directURL != null && general.directURL.StartsWith("https://www.moddb.com/downloads/start")) + { + result = new MODDBArchive() + { + URL = general.directURL + }; + } else if (general.directURL != null) { result = new DirectURLArchive() @@ -338,13 +363,15 @@ namespace Wabbajack IgnoreStartsWith("logs\\"), IgnoreStartsWith("downloads\\"), IgnoreStartsWith("webcache\\"), - IgnoreStartsWith("nxmhandler."), IgnoreEndsWith(".pyc"), IgnoreOtherProfiles(), IgnoreDisabledMods(), IncludeThisProfile(), // Ignore the ModOrganizer.ini file it contains info created by MO2 on startup IgnoreStartsWith("ModOrganizer.ini"), + IgnoreStartsWith(Path.Combine(Consts.GameFolderFilesDir, "Data")), + IgnoreStartsWith(Path.Combine(Consts.GameFolderFilesDir, "Papyrus Compiler")), + IgnoreStartsWith(Path.Combine(Consts.GameFolderFilesDir, "Skyrim")), IgnoreRegex(Consts.GameFolderFilesDir + "\\\\.*\\.bsa"), IncludeModIniData(), DirectMatch(), diff --git a/Wabbajack/Installer.cs b/Wabbajack/Installer.cs index 31c81eef..aa4c30e7 100644 --- a/Wabbajack/Installer.cs +++ b/Wabbajack/Installer.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Net.Http; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Wabbajack.Common; @@ -203,6 +204,10 @@ namespace Wabbajack var url = NexusAPI.GetNexusDownloadLink(archive as NexusMod, NexusAPIKey); DownloadURLDirect(archive, url); } + else if (archive is MODDBArchive) + { + DownloadModDBArchive(archive, (archive as MODDBArchive).URL); + } else if (archive is DirectURLArchive) { DownloadURLDirect(archive, (archive as DirectURLArchive).URL); @@ -214,6 +219,15 @@ namespace Wabbajack }); } + private void DownloadModDBArchive(Archive archive, string url) + { + var client = new HttpClient(); + var result = client.GetStringSync(url); + var regex = new Regex("https:\\/\\/www\\.moddb\\.com\\/downloads\\/mirror\\/.*(?=\\\")"); + var match = regex.Match(result); + DownloadURLDirect(archive, match.Value); + } + private void DownloadURLDirect(Archive archive, string url) { HttpClient client = new HttpClient(); @@ -225,7 +239,10 @@ namespace Wabbajack var stream = response.Content.ReadAsStreamAsync(); stream.Wait(); - var header = response.Content.Headers.GetValues("Content-Length").FirstOrDefault(); + string header = "1"; + if (response.Content.Headers.Contains("Content-Length")) + header = response.Content.Headers.GetValues("Content-Length").FirstOrDefault(); + long content_size = header != null ? long.Parse(header) : 1; var output_path = Path.Combine(DownloadFolder, archive.Name); diff --git a/Wabbajack/MainWindow.xaml.cs b/Wabbajack/MainWindow.xaml.cs index 9867bb49..6adc9e53 100644 --- a/Wabbajack/MainWindow.xaml.cs +++ b/Wabbajack/MainWindow.xaml.cs @@ -32,9 +32,11 @@ namespace Wabbajack new Thread(() => { compiler.LoadArchives(); - compiler.MO2Profile = "Lexy's Legacy of The Dragonborn Special Edition"; + compiler.MO2Profile = "Basic Graphics and Fixes"; compiler.Compile(); + compiler.ModList.ToJSON("C:\\tmp\\modpack.json"); + var installer = new Installer(compiler.ModList, "c:\\tmp\\install\\", msg => context.LogMsg(msg)); installer.Install(); diff --git a/Wabbajack/NexusAPI.cs b/Wabbajack/NexusAPI.cs index c0ccd1fe..d00e3802 100644 --- a/Wabbajack/NexusAPI.cs +++ b/Wabbajack/NexusAPI.cs @@ -39,9 +39,9 @@ namespace Wabbajack }; _websocket.Connect(); - _websocket.Send("{\"id\": \"" + guid + "\", \"appid\": \"Wabbajack\"}"); + _websocket.Send("{\"id\": \"" + guid + "\", \"appid\": \""+ Consts.AppName+"\"}"); - Process.Start($"https://www.nexusmods.com/sso?id={guid}&application=Wabbajack"); + Process.Start($"https://www.nexusmods.com/sso?id={guid}&application=" + Consts.AppName); api_key.Task.Wait(); var result = api_key.Task.Result; @@ -59,7 +59,7 @@ namespace Wabbajack _baseHttpClient.DefaultRequestHeaders.Add("User-Agent", Consts.UserAgent); _baseHttpClient.DefaultRequestHeaders.Add("apikey", apikey); _baseHttpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - _baseHttpClient.DefaultRequestHeaders.Add("Application-Name", "Wabbajack"); + _baseHttpClient.DefaultRequestHeaders.Add("Application-Name", Consts.AppName); _baseHttpClient.DefaultRequestHeaders.Add("Application-Version", $"{Assembly.GetEntryAssembly().GetName().Version}"); return _baseHttpClient; } diff --git a/Wabbajack/Wabbajack.csproj b/Wabbajack/Wabbajack.csproj index 50f8671f..67d9de78 100644 --- a/Wabbajack/Wabbajack.csproj +++ b/Wabbajack/Wabbajack.csproj @@ -46,6 +46,7 @@ +