-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
328 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using CouchDB.Driver.Types; | ||
|
||
namespace cesi.DTOs; | ||
|
||
public class Analyzed : CouchDocument | ||
{ | ||
|
||
public string xxHash64 { get; set; } | ||
public string MD5 { get; set; } | ||
public string SHA1 { get; set; } | ||
public string SHA256 { get; set; } | ||
public string SHA512 { get; set; } | ||
public string CRC32 { get; set; } | ||
public long Size { get; set; } | ||
public Archive? Archive { get; set; } | ||
public Plugin? Plugin { get; set; } | ||
public DDS? DDS { get; set; } | ||
public Source[]? Source { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace cesi.DTOs; | ||
|
||
public class Archive | ||
{ | ||
public string Type { get; set; } | ||
public Dictionary<string, string> Entries { get; set; } = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace cesi.DTOs; | ||
|
||
public class DDS | ||
{ | ||
public int Width { get; set; } | ||
public int Height { get; set; } | ||
public string Format { get; set; } | ||
public string PHash { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace cesi.DTOs; | ||
|
||
public class Plugin | ||
{ | ||
public string Name { get; set; } | ||
public string Author { get; set; } | ||
public string Description { get; set; } | ||
public uint FormVersion { get; set; } | ||
public string ModType { get; set; } | ||
public bool IsMaster { get; set; } | ||
public bool IsLightMaster { get; set; } | ||
public string[] MasterReferences { get; set; } = Array.Empty<string>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace cesi.DTOs; | ||
|
||
public class Source | ||
{ | ||
public NexusSource? Nexus { get; set; } | ||
} | ||
|
||
public class NexusSource | ||
{ | ||
public string Game { get; set; } | ||
public long ModId { get; set; } | ||
public long FileId { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CouchDB.NET" Version="3.1.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Drawing; | ||
using Shipwreck.Phash; | ||
using Wabbajack.DTOs.Texture; | ||
using Wabbajack.Hashing.PHash; | ||
using Wabbajack.Hashing.xxHash64; | ||
using Wabbajack.Paths; | ||
|
||
namespace cesi.Analyzers; | ||
|
||
public class DDS : Analyzer<cesi.DTOs.DDS> | ||
{ | ||
protected override async Task<DTOs.DDS?> Analyze(Stream stream, Func<AbsolutePath, Task> analyzeSubFile, CancellationToken token) | ||
{ | ||
try | ||
{ | ||
|
||
var data = await ImageLoader.Load(stream); | ||
return new DTOs.DDS | ||
{ | ||
Width = data.Width, | ||
Height = data.Height, | ||
Format = data.Format.ToString(), | ||
PHash = data.PerceptualHash.Data.ToHex() | ||
}; | ||
} | ||
catch (Exception ex) | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
public override string Name => "DDS"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Text.Json; | ||
using Mutagen.Bethesda.Fallout4; | ||
using Mutagen.Bethesda.Plugins; | ||
using Mutagen.Bethesda.Skyrim; | ||
using Wabbajack.Common; | ||
using Wabbajack.Common.FileSignatures; | ||
using Wabbajack.Paths; | ||
|
||
namespace cesi.Analyzers; | ||
|
||
public class Plugin : IAnalyzer | ||
{ | ||
public string Name => "Plugin"; | ||
public Type DTOType => throw new NotImplementedException(); | ||
public IEnumerable<FileType> LimitSignatures { get; } | ||
|
||
private HashSet<Extension> Extensions = new() {Ext.Esp, Ext.Esm, new Extension(".esl")}; | ||
public async Task Analyze(Utf8JsonWriter writer, JsonSerializerOptions options, AbsolutePath path, Func<AbsolutePath, Task> analyzeSubFile, | ||
CancellationToken token) | ||
{ | ||
if (!Extensions.Contains(path.Extension)) return; | ||
|
||
var file = SkyrimMod.CreateFromBinary(new ModPath(path.ToString()), SkyrimRelease.SkyrimSE); | ||
|
||
writer.WritePropertyName("Plugin"); | ||
writer.WriteStartObject(); | ||
writer.WriteString("Name", file.ModKey.FileName); | ||
writer.WriteString("Author", file.ModHeader.Author); | ||
writer.WriteString("Description", file.ModHeader.Description); | ||
writer.WriteNumber("FormVersion", file.ModHeader.FormVersion); | ||
writer.WriteString("ModType", file.ModKey.Type.ToString()); | ||
writer.WriteBoolean("IsLightMaster", file.ModHeader.Flags.HasFlag(SkyrimModHeader.HeaderFlag.LightMaster)); | ||
writer.WriteBoolean("IsMaster", file.ModHeader.Flags.HasFlag(SkyrimModHeader.HeaderFlag.Master)); | ||
if (file.ModHeader.MasterReferences.Any()) | ||
{ | ||
writer.WritePropertyName("MasterReferences"); | ||
writer.WriteStartArray(); | ||
foreach (var master in file.ModHeader.MasterReferences) | ||
{ | ||
writer.WriteStringValue(master.Master.FileName); | ||
} | ||
writer.WriteEndArray(); | ||
} | ||
|
||
writer.WriteEndObject(); | ||
|
||
return; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System.Text.Json; | ||
using Wabbajack.Common; | ||
using Wabbajack.Common.FileSignatures; | ||
using Wabbajack.Downloaders; | ||
using Wabbajack.DTOs; | ||
using Wabbajack.DTOs.DownloadStates; | ||
using Wabbajack.Installer; | ||
using Wabbajack.Paths; | ||
using Wabbajack.Paths.IO; | ||
|
||
namespace cesi.Analyzers; | ||
|
||
public class Source : IAnalyzer | ||
{ | ||
private readonly DownloadDispatcher _dispatcher; | ||
public string Name { get; } | ||
public Type DTOType { get; } | ||
public IEnumerable<FileType> LimitSignatures { get; } | ||
|
||
public Source(DownloadDispatcher dispatcher) | ||
{ | ||
_dispatcher = dispatcher; | ||
} | ||
|
||
public async Task Analyze(Utf8JsonWriter writer, JsonSerializerOptions options, AbsolutePath path, Func<AbsolutePath, Task> analyzeSubFile, | ||
CancellationToken token) | ||
{ | ||
var meta = path.WithExtension(Ext.Meta); | ||
if (!meta.FileExists()) | ||
return; | ||
|
||
var ini = await _dispatcher.ResolveArchive(meta.LoadIniFile()["General"] | ||
.ToDictionary(d => d.KeyName, d => d.Value)); | ||
if (ini == null) return; | ||
|
||
writer.WritePropertyName("Source"); | ||
writer.WriteStartArray(); | ||
|
||
writer.WriteStartObject(); | ||
switch (ini) | ||
{ | ||
case Nexus n: | ||
writer.WritePropertyName("Nexus"); | ||
writer.WriteStartObject(); | ||
|
||
writer.WriteString("Game", n.Game.MetaData().NexusName); | ||
writer.WriteNumber("ModId", n.ModID); | ||
writer.WriteNumber("Number", n.FileID); | ||
|
||
writer.WriteEndObject(); | ||
|
||
break; | ||
case GameFileSource g: | ||
writer.WritePropertyName("GameFile"); | ||
writer.WriteStartObject(); | ||
|
||
writer.WriteString("Game", g.Game.ToString()); | ||
writer.WriteString("Version", g.GameVersion); | ||
writer.WriteString("Path", g.GameFile.ToString()); | ||
|
||
writer.WriteEndObject(); | ||
break; | ||
case Http h: | ||
writer.WritePropertyName("Http"); | ||
writer.WriteStartObject(); | ||
|
||
writer.WriteString("Url", h.Url.ToString()); | ||
|
||
writer.WriteEndObject(); | ||
break; | ||
default: | ||
throw new NotImplementedException(); | ||
|
||
} | ||
|
||
writer.WriteEndObject(); | ||
writer.WriteEndArray(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.