Skip to content

Commit

Permalink
added a meta file generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kezyma committed Jan 17, 2024
1 parent 1491e4f commit 95a16ca
Show file tree
Hide file tree
Showing 18 changed files with 248 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ tools/*_log.txt
tools/temp
web
debug
tools/meta-generator/obj
tools/meta-generator/bin
5 changes: 5 additions & 0 deletions tools/Meta/curationclub.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[General]
installed=true
gameName=skyrimse
modID=60552
fileID=350066
5 changes: 5 additions & 0 deletions tools/Meta/openmwplayer.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[General]
installed=true
gameName=morrowind
modID=52345
fileID=1000041309
5 changes: 5 additions & 0 deletions tools/Meta/pluginfinder.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[General]
installed=true
gameName=skyrimse
modID=59869
fileID=448756
5 changes: 5 additions & 0 deletions tools/Meta/profilesync.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[General]
installed=true
gameName=skyrimse
modID=60690
fileID=461278
5 changes: 5 additions & 0 deletions tools/Meta/reinstaller.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[General]
installed=true
gameName=skyrimse
modID=59292
fileID=461962
5 changes: 5 additions & 0 deletions tools/Meta/rootbuilder.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[General]
installed=true
gameName=skyrimse
modID=31720
fileID=460345
5 changes: 5 additions & 0 deletions tools/Meta/shortcutter.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[General]
installed=true
gameName=skyrimse
modID=59827
fileID=461963
Binary file added tools/MetaGenerator.exe
Binary file not shown.
Binary file added tools/MetaGenerator.pdb
Binary file not shown.
44 changes: 44 additions & 0 deletions tools/Plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[
{
"PluginId": "rootbuilder",
"GameId": "skyrimspecialedition",
"NexusId": 31720,
"MO2Game": "skyrimse"
},
{
"PluginId": "reinstaller",
"GameId": "skyrimspecialedition",
"NexusId": 59292,
"MO2Game": "skyrimse"
},
{
"PluginId": "shortcutter",
"GameId": "skyrimspecialedition",
"NexusId": 59827,
"MO2Game": "skyrimse"
},
{
"PluginId": "pluginfinder",
"GameId": "skyrimspecialedition",
"NexusId": 59869,
"MO2Game": "skyrimse"
},
{
"PluginId": "curationclub",
"GameId": "skyrimspecialedition",
"NexusId": 60552,
"MO2Game": "skyrimse"
},
{
"PluginId": "profilesync",
"GameId": "skyrimspecialedition",
"NexusId": 60690,
"MO2Game": "skyrimse"
},
{
"PluginId": "openmwplayer",
"GameId": "morrowind",
"NexusId": 52345,
"MO2Game": "morrowind"
}
]
20 changes: 20 additions & 0 deletions tools/meta-generator/MetaGenerator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<None Update="Plugins.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions tools/meta-generator/MetaGenerator.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>D:\Repos\ModOrganizer-Plugins\tools\meta-generator\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
25 changes: 25 additions & 0 deletions tools/meta-generator/MetaGenerator.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetaGenerator", "MetaGenerator.csproj", "{D5001B49-8F4D-497C-8137-40A0CFDF7CB0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D5001B49-8F4D-497C-8137-40A0CFDF7CB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5001B49-8F4D-497C-8137-40A0CFDF7CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5001B49-8F4D-497C-8137-40A0CFDF7CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5001B49-8F4D-497C-8137-40A0CFDF7CB0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {32435DAB-024E-49A7-BB61-DA7F13E2AAAB}
EndGlobalSection
EndGlobal
44 changes: 44 additions & 0 deletions tools/meta-generator/Plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[
{
"PluginId": "rootbuilder",
"GameId": "skyrimspecialedition",
"NexusId": 31720,
"MO2Game": "skyrimse"
},
{
"PluginId": "reinstaller",
"GameId": "skyrimspecialedition",
"NexusId": 59292,
"MO2Game": "skyrimse"
},
{
"PluginId": "shortcutter",
"GameId": "skyrimspecialedition",
"NexusId": 59827,
"MO2Game": "skyrimse"
},
{
"PluginId": "pluginfinder",
"GameId": "skyrimspecialedition",
"NexusId": 59869,
"MO2Game": "skyrimse"
},
{
"PluginId": "curationclub",
"GameId": "skyrimspecialedition",
"NexusId": 60552,
"MO2Game": "skyrimse"
},
{
"PluginId": "profilesync",
"GameId": "skyrimspecialedition",
"NexusId": 60690,
"MO2Game": "skyrimse"
},
{
"PluginId": "openmwplayer",
"GameId": "morrowind",
"NexusId": 52345,
"MO2Game": "morrowind"
}
]
43 changes: 43 additions & 0 deletions tools/meta-generator/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Newtonsoft.Json;
using System.Text.RegularExpressions;

namespace MetaGenerator
{
internal class Program
{
public static string FileIdRegex = $"file_id=(?<fileId>[0-9]*)";
public class Plugin
{
public string PluginId { get; set; }
public string GameId { get; set; }
public int NexusId { get; set; }
public string MO2Game { get; set; }
}

static void Main(string[] args)
{
var json = Path.GetFullPath("Plugins.json");
var dest = Path.GetFullPath("Meta");
if (!Directory.Exists(dest)) Directory.CreateDirectory(dest);
if (File.Exists(json))
{
Console.WriteLine("Reading Plugins.json");
var text = File.ReadAllText(json);
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);
}
}
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>..\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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>
<LastFailureDetails />
</PropertyGroup>
</Project>

0 comments on commit 95a16ca

Please sign in to comment.