Skip to content

Commit

Permalink
moved the meta stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Kezyma committed Jan 18, 2024
1 parent 95a16ca commit 6ecdb8c
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 10 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file modified tools/MetaGenerator.exe
Binary file not shown.
Binary file modified tools/MetaGenerator.pdb
Binary file not shown.
23 changes: 14 additions & 9 deletions tools/meta-generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Plugin
static void Main(string[] args)
{
var json = Path.GetFullPath("Plugins.json");
var dest = Path.GetFullPath("Meta");
var dest = Path.GetFullPath("..\\meta");
if (!Directory.Exists(dest)) Directory.CreateDirectory(dest);
if (File.Exists(json))
{
Expand All @@ -26,14 +26,19 @@ static void Main(string[] args)
var plugins = JsonConvert.DeserializeObject<List<Plugin>>(text);
foreach (var plugin in plugins)
{
Console.WriteLine($"Generating meta file for {plugin.PluginId}");
using var client = new HttpClient();
var res = client.GetAsync($"https://www.nexusmods.com/{plugin.GameId}/mods/{plugin.NexusId}?tab=files").Result;
var html = res.Content.ReadAsStringAsync().Result;
var match = Regex.Match(html, FileIdRegex);
var fileId = match.Groups["fileId"].Value;
var metaString = $"[General]\ninstalled=true\ngameName={plugin.MO2Game}\nmodID={plugin.NexusId}\nfileID={fileId}";
File.WriteAllText(Path.Combine(dest, $"{plugin.PluginId}.meta"), metaString);
var metaFilePath = Path.Combine(dest, $"{plugin.PluginId}.meta");
if (!File.Exists(metaFilePath))
{
Console.WriteLine($"Generating meta file for {plugin.PluginId}");
using var client = new HttpClient();
var res = client.GetAsync($"https://www.nexusmods.com/{plugin.GameId}/mods/{plugin.NexusId}?tab=files").Result;
var html = res.Content.ReadAsStringAsync().Result;
var match = Regex.Match(html, FileIdRegex);
var fileId = match.Groups["fileId"].Value;
var metaString = $"[General]\ninstalled=true\ngameName={plugin.MO2Game}\nmodID={plugin.NexusId}\nfileID={fileId}";
File.WriteAllText(metaFilePath, metaString);
Thread.Sleep(1000);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-01-17T23:50:21.3986473Z;True|2024-01-17T23:50:04.9398037+00:00;True|2024-01-17T23:49:12.9538402+00:00;True|2024-01-17T23:44:49.7712607+00:00;</History>
<History>True|2024-01-18T00:01:09.8412462Z;True|2024-01-17T23:59:48.3318025+00:00;True|2024-01-17T23:58:51.6457721+00:00;True|2024-01-17T23:50:21.3986473+00:00;True|2024-01-17T23:50:04.9398037+00:00;True|2024-01-17T23:49:12.9538402+00:00;True|2024-01-17T23:44:49.7712607+00:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

0 comments on commit 6ecdb8c

Please sign in to comment.