Removed classes that have been moved to the parser nuget package (#82)
This commit is contained in:
21
.github/workflows/BuildDockerOnTag.yml
vendored
21
.github/workflows/BuildDockerOnTag.yml
vendored
@@ -9,31 +9,24 @@ jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: 'true'
|
||||
-
|
||||
name: Install dotnet tool
|
||||
- name: Install dotnet tool
|
||||
run: dotnet tool install -g dotnetCampus.TagToVersion
|
||||
-
|
||||
name: Set tag to version
|
||||
- name: Set tag to version
|
||||
run: dotnet TagToVersion -t ${{ github.ref }}
|
||||
-
|
||||
name: Set up QEMU
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to Docker Hub
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
|
26
Gaseous.sln
26
Gaseous.sln
@@ -1,16 +1,8 @@
|
||||
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 25.0.1704.4
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gaseous-identifier-testapp", "gaseous-identifier\gaseous-identifier-testapp.csproj", "{F5C42134-5372-430A-A9AE-1871981850DB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gaseous-signature-parser", "gaseous-signature-parser\gaseous-signature-parser.csproj", "{DAEBBB82-5051-43FD-A406-F9D64A38F468}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gaseous-romsignatureobject", "gaseous-romsignatureobject\gaseous-romsignatureobject.csproj", "{9DCD243D-37CE-4562-8411-B5242B687D4F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gaseous-signature-ingestor", "gaseous-signature-ingestor\gaseous-signature-ingestor.csproj", "{86DF6E45-2C2B-4C30-AEC1-E7EF8C5CEA7D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gaseous-tools", "gaseous-tools\gaseous-tools.csproj", "{08FE408A-5EC1-4110-ABD8-D19A1155B8CE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gaseous-server", "gaseous-server\gaseous-server.csproj", "{A01D2EFF-C82E-473B-84D7-7C25E736F5D2}"
|
||||
@@ -37,30 +29,14 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F5C42134-5372-430A-A9AE-1871981850DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F5C42134-5372-430A-A9AE-1871981850DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F5C42134-5372-430A-A9AE-1871981850DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F5C42134-5372-430A-A9AE-1871981850DB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{08699C93-15CD-4E39-9053-D3C8056CE938}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{08699C93-15CD-4E39-9053-D3C8056CE938}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{08699C93-15CD-4E39-9053-D3C8056CE938}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{08699C93-15CD-4E39-9053-D3C8056CE938}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DAEBBB82-5051-43FD-A406-F9D64A38F468}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DAEBBB82-5051-43FD-A406-F9D64A38F468}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DAEBBB82-5051-43FD-A406-F9D64A38F468}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DAEBBB82-5051-43FD-A406-F9D64A38F468}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FFCEC386-033F-4772-A45B-D33579F2E5EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FFCEC386-033F-4772-A45B-D33579F2E5EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FFCEC386-033F-4772-A45B-D33579F2E5EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FFCEC386-033F-4772-A45B-D33579F2E5EE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9DCD243D-37CE-4562-8411-B5242B687D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9DCD243D-37CE-4562-8411-B5242B687D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9DCD243D-37CE-4562-8411-B5242B687D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9DCD243D-37CE-4562-8411-B5242B687D4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{86DF6E45-2C2B-4C30-AEC1-E7EF8C5CEA7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{86DF6E45-2C2B-4C30-AEC1-E7EF8C5CEA7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{86DF6E45-2C2B-4C30-AEC1-E7EF8C5CEA7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{86DF6E45-2C2B-4C30-AEC1-E7EF8C5CEA7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{08FE408A-5EC1-4110-ABD8-D19A1155B8CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{08FE408A-5EC1-4110-ABD8-D19A1155B8CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{08FE408A-5EC1-4110-ABD8-D19A1155B8CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@@ -1,183 +0,0 @@
|
||||
// parse command line
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using gaseous_romsignatureobject;
|
||||
using gaseous_signature_parser.parsers;
|
||||
|
||||
string[] commandLineArgs = Environment.GetCommandLineArgs();
|
||||
|
||||
string scanPath = "./";
|
||||
string tosecXML = "";
|
||||
|
||||
string inArgument = "";
|
||||
foreach (string commandLineArg in commandLineArgs)
|
||||
{
|
||||
if (commandLineArg != commandLineArgs[0])
|
||||
{
|
||||
if (inArgument == "")
|
||||
{
|
||||
switch (commandLineArg.ToLower())
|
||||
{
|
||||
case "-scanpath":
|
||||
inArgument = commandLineArg.ToLower();
|
||||
break;
|
||||
case "-tosecpath":
|
||||
inArgument = commandLineArg.ToLower();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (inArgument)
|
||||
{
|
||||
case "-scanpath":
|
||||
scanPath = commandLineArg;
|
||||
break;
|
||||
case "-tosecpath":
|
||||
tosecXML = commandLineArg;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
inArgument = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scanPath = Path.GetFullPath(scanPath);
|
||||
Console.WriteLine("ROM search path: " + scanPath);
|
||||
|
||||
List<RomSignatureObject> romSignatures = new List<RomSignatureObject>();
|
||||
System.Collections.ArrayList availablePlatforms = new System.Collections.ArrayList();
|
||||
|
||||
// load TOSEC XML files
|
||||
if (tosecXML != null && tosecXML.Length > 0)
|
||||
{
|
||||
tosecXML = Path.GetFullPath(tosecXML);
|
||||
Console.WriteLine("TOSEC is enabled");
|
||||
Console.WriteLine("TOSEC XML search path: " + tosecXML);
|
||||
|
||||
string[] tosecPathContents = Directory.GetFiles(tosecXML);
|
||||
int lastCLILineLength = 0;
|
||||
for (UInt16 i = 0; i < tosecPathContents.Length; ++i)
|
||||
{
|
||||
string tosecXMLFile = tosecPathContents[i];
|
||||
|
||||
TosecParser tosecParser = new TosecParser();
|
||||
RomSignatureObject tosecObject = tosecParser.Parse(tosecXMLFile);
|
||||
|
||||
string statusOutput = i + " / " + tosecPathContents.Length + " : " + Path.GetFileName(tosecXMLFile);
|
||||
Console.Write("\r " + statusOutput.PadRight(lastCLILineLength, ' ') + "\r");
|
||||
lastCLILineLength = statusOutput.Length;
|
||||
|
||||
foreach (RomSignatureObject.Game gameRom in tosecObject.Games)
|
||||
{
|
||||
if (!availablePlatforms.Contains(gameRom.System))
|
||||
{
|
||||
availablePlatforms.Add(gameRom.System);
|
||||
}
|
||||
}
|
||||
|
||||
romSignatures.Add(tosecObject);
|
||||
}
|
||||
Console.WriteLine("");
|
||||
} else
|
||||
{
|
||||
Console.WriteLine("TOSEC is disabled.");
|
||||
}
|
||||
Console.WriteLine(romSignatures.Count + " TOSEC files loaded");
|
||||
|
||||
// Summarise signatures
|
||||
if (availablePlatforms.Count > 0)
|
||||
{
|
||||
availablePlatforms.Sort();
|
||||
Console.WriteLine("Platforms loaded:");
|
||||
foreach (string platform in availablePlatforms)
|
||||
{
|
||||
Console.WriteLine(" * " + platform);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Examining files");
|
||||
string[] romPathContents = Directory.GetFiles(scanPath);
|
||||
foreach (string romFile in romPathContents)
|
||||
{
|
||||
Console.WriteLine("Checking " + romFile);
|
||||
|
||||
var stream = File.OpenRead(romFile);
|
||||
|
||||
var md5 = MD5.Create();
|
||||
byte[] md5HashByte = md5.ComputeHash(stream);
|
||||
string md5Hash = BitConverter.ToString(md5HashByte).Replace("-", "").ToLowerInvariant();
|
||||
|
||||
var sha1 = SHA1.Create();
|
||||
byte[] sha1HashByte = sha1.ComputeHash(stream);
|
||||
string sha1Hash = BitConverter.ToString(sha1HashByte).Replace("-", "").ToLowerInvariant();
|
||||
|
||||
bool gameFound = false;
|
||||
foreach (RomSignatureObject tosecList in romSignatures)
|
||||
{
|
||||
foreach (RomSignatureObject.Game gameObject in tosecList.Games)
|
||||
{
|
||||
foreach (RomSignatureObject.Game.Rom romObject in gameObject.Roms)
|
||||
{
|
||||
if (romObject.Md5 != null)
|
||||
{
|
||||
if (md5Hash == romObject.Md5.ToLowerInvariant())
|
||||
{
|
||||
// match
|
||||
gameFound = true;
|
||||
}
|
||||
}
|
||||
if (romObject.Sha1 != null)
|
||||
{
|
||||
if (md5Hash == romObject.Sha1.ToLowerInvariant())
|
||||
{
|
||||
// match
|
||||
gameFound = true;
|
||||
}
|
||||
}
|
||||
if (gameFound == true)
|
||||
{
|
||||
Console.WriteLine(romObject.Name);
|
||||
|
||||
RomSignatureObject.Game gameSignature = gameObject;
|
||||
gameSignature.Roms.Clear();
|
||||
gameSignature.Roms.Add(romObject);
|
||||
|
||||
var jsonSerializerSettings = new JsonSerializerSettings();
|
||||
jsonSerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
|
||||
jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore;
|
||||
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(gameSignature, Newtonsoft.Json.Formatting.Indented, jsonSerializerSettings));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (gameFound == true) { break; }
|
||||
}
|
||||
if (gameFound == true) { break; }
|
||||
}
|
||||
if (gameFound == false)
|
||||
{
|
||||
Console.WriteLine("File not found in TOSEC library");
|
||||
}
|
||||
}
|
||||
|
||||
string SearchTitle = "California Games";
|
||||
foreach (RomSignatureObject romSignatureObject in romSignatures)
|
||||
{
|
||||
foreach (RomSignatureObject.Game gameObject in romSignatureObject.Games)
|
||||
{
|
||||
if (gameObject.Name == SearchTitle)
|
||||
{
|
||||
var jsonSerializerSettings = new JsonSerializerSettings();
|
||||
jsonSerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
|
||||
jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore;
|
||||
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(gameObject, Newtonsoft.Json.Formatting.Indented, jsonSerializerSettings));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RootNamespace>gaseous_identifier</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Newtonsoft.Json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\gaseous-romsignatureobject\gaseous-romsignatureobject.csproj" />
|
||||
<ProjectReference Include="..\gaseous-signature-parser\gaseous-signature-parser.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,125 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace gaseous_romsignatureobject
|
||||
{
|
||||
/// <summary>
|
||||
/// Object returned by all signature engines containing metadata about the ROM's in the data files
|
||||
///
|
||||
/// This class was based on the TOSEC dataset, so may need to be expanded as new signature engines are added
|
||||
/// </summary>
|
||||
public class RomSignatureObject
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Category { get; set; }
|
||||
public string? Version { get; set; }
|
||||
public string? Author { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Homepage { get; set; }
|
||||
public Uri? Url { get; set; }
|
||||
public string? SourceType { get; set; }
|
||||
public string SourceMd5 { get; set; } = "";
|
||||
public string SourceSHA1 { get; set; } = "";
|
||||
|
||||
public List<Game> Games { get; set; } = new List<Game>();
|
||||
|
||||
public class Game
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Year { get; set; }
|
||||
public string? Publisher { get; set; }
|
||||
public DemoTypes Demo { get; set; }
|
||||
public string? System { get; set; }
|
||||
public string? SystemVariant { get; set; }
|
||||
public string? Video { get; set; }
|
||||
public string? Country { get; set; }
|
||||
public string? Language { get; set; }
|
||||
public string? Copyright { get; set; }
|
||||
public List<Rom> Roms { get; set; } = new List<Rom>();
|
||||
public int RomCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return Roms.Count();
|
||||
}
|
||||
}
|
||||
|
||||
public enum DemoTypes
|
||||
{
|
||||
NotDemo = 0,
|
||||
demo = 1,
|
||||
demo_kiosk = 2,
|
||||
demo_playable = 3,
|
||||
demo_rolling = 4,
|
||||
demo_slideshow = 5
|
||||
}
|
||||
|
||||
public class Rom
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public UInt64? Size { get; set; }
|
||||
public string? Crc { get; set; }
|
||||
public string? Md5 { get; set; }
|
||||
public string? Sha1 { get; set; }
|
||||
|
||||
public string? DevelopmentStatus { get; set; }
|
||||
|
||||
public List<string> flags { get; set; } = new List<string>();
|
||||
|
||||
public RomTypes RomType { get; set; }
|
||||
public string? RomTypeMedia { get; set; }
|
||||
public string? MediaLabel { get; set; }
|
||||
|
||||
public SignatureSourceType SignatureSource { get; set; }
|
||||
|
||||
public enum SignatureSourceType
|
||||
{
|
||||
None = 0,
|
||||
TOSEC = 1
|
||||
}
|
||||
|
||||
public enum RomTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Media type is unknown
|
||||
/// </summary>
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Optical media
|
||||
/// </summary>
|
||||
Disc = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Magnetic media
|
||||
/// </summary>
|
||||
Disk = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Individual files
|
||||
/// </summary>
|
||||
File = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Individual pars
|
||||
/// </summary>
|
||||
Part = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Tape base media
|
||||
/// </summary>
|
||||
Tape = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Side of the media
|
||||
/// </summary>
|
||||
Side = 6
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RootNamespace>gaseous_romsignatureobject</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using MySql.Data.MySqlClient;
|
||||
using gaseous_romsignatureobject;
|
||||
using gaseous_signature_parser.parsers;
|
||||
using gaseous_signature_parser.models.RomSignatureObject;
|
||||
using gaseous_signature_parser.classes.parsers;
|
||||
using gaseous_tools;
|
||||
using MySqlX.XDevAPI;
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using static gaseous_romsignatureobject.RomSignatureObject.Game;
|
||||
|
||||
namespace gaseous_server.Models
|
||||
{
|
||||
|
@@ -18,6 +18,7 @@
|
||||
<DocumentationFile>bin\Release\net7.0\gaseous-server.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="gaseous-signature-parser" Version="1.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.9" />
|
||||
@@ -112,12 +113,6 @@
|
||||
<ProjectReference Include="..\gaseous-tools\gaseous-tools.csproj">
|
||||
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\gaseous-romsignatureobject\gaseous-romsignatureobject.csproj">
|
||||
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\gaseous-signature-parser\gaseous-signature-parser.csproj">
|
||||
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Support\PlatformMap.json" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'">
|
||||
|
@@ -1,285 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using MySql.Data.MySqlClient;
|
||||
using gaseous_romsignatureobject;
|
||||
using gaseous_signature_parser.parsers;
|
||||
using gaseous_tools;
|
||||
using MySqlX.XDevAPI;
|
||||
|
||||
// process command line
|
||||
string[] commandLineArgs = Environment.GetCommandLineArgs();
|
||||
|
||||
string tosecXML = "";
|
||||
bool showGames = false;
|
||||
string inArgument = "";
|
||||
foreach (string commandLineArg in commandLineArgs)
|
||||
{
|
||||
if (commandLineArg != commandLineArgs[0])
|
||||
{
|
||||
if (inArgument == "")
|
||||
{
|
||||
switch (commandLineArg.ToLower())
|
||||
{
|
||||
case "-tosecpath":
|
||||
inArgument = commandLineArg.ToLower();
|
||||
break;
|
||||
case "-showgames":
|
||||
showGames = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (inArgument)
|
||||
{
|
||||
case "-tosecpath":
|
||||
tosecXML = commandLineArg;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
inArgument = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if Config.ConfigurationPath is valid and create it if not
|
||||
if (!Directory.Exists(Config.ConfigurationPath))
|
||||
{
|
||||
Directory.CreateDirectory(Config.ConfigurationPath);
|
||||
}
|
||||
|
||||
// connect to database
|
||||
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||
// initialise the db
|
||||
db.InitDB();
|
||||
|
||||
// process provided files
|
||||
Console.WriteLine("Processing input files:");
|
||||
if (Directory.Exists(tosecXML))
|
||||
{
|
||||
Console.WriteLine("Processing TOSEC data files", ConsoleColor.Green);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
|
||||
tosecXML = Path.GetFullPath(tosecXML);
|
||||
string[] tosecPathContents = Directory.GetFiles(tosecXML);
|
||||
Array.Sort(tosecPathContents);
|
||||
int lineFileNameLength = 0;
|
||||
int lineGameNameLength = 0;
|
||||
|
||||
string sql = "";
|
||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||
System.Data.DataTable sigDB;
|
||||
|
||||
for (UInt16 i = 0; i < tosecPathContents.Length; ++i)
|
||||
{
|
||||
string tosecXMLFile = tosecPathContents[i];
|
||||
|
||||
string statusOutput = (i + 1).ToString().PadLeft(7, ' ') + " / " + tosecPathContents.Length.ToString().PadLeft(7, ' ') + " : " + Path.GetFileName(tosecXMLFile);
|
||||
Console.SetCursorPosition(0, Console.CursorTop - 2);
|
||||
Console.WriteLine("\r " + statusOutput.PadRight(lineFileNameLength, ' ') + "\r");
|
||||
lineFileNameLength = statusOutput.Length;
|
||||
|
||||
// check tosec file md5
|
||||
Console.WriteLine(" ==> Checking input file ");
|
||||
Common.hashObject hashObject = new Common.hashObject(tosecXMLFile);
|
||||
sql = "SELECT * FROM Signatures_Sources WHERE SourceMD5=@sourcemd5";
|
||||
dbDict = new Dictionary<string, object>();
|
||||
dbDict.Add("sourcemd5", hashObject.md5hash);
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
|
||||
if (sigDB.Rows.Count == 0)
|
||||
{
|
||||
// start parsing file
|
||||
Console.SetCursorPosition(0, Console.CursorTop - 1);
|
||||
Console.WriteLine(" ==> Parsing file ");
|
||||
TosecParser tosecParser = new TosecParser();
|
||||
RomSignatureObject tosecObject = tosecParser.Parse(tosecXMLFile);
|
||||
|
||||
// store in database
|
||||
|
||||
// store source object
|
||||
bool processGames = false;
|
||||
if (tosecObject.SourceMd5 != null)
|
||||
{
|
||||
Console.SetCursorPosition(0, Console.CursorTop - 1);
|
||||
Console.WriteLine(" ==> Storing file in database ");
|
||||
|
||||
sql = "SELECT * FROM Signatures_Sources WHERE SourceMD5=@sourcemd5";
|
||||
dbDict = new Dictionary<string, object>();
|
||||
dbDict.Add("name", Common.ReturnValueIfNull(tosecObject.Name, ""));
|
||||
dbDict.Add("description", Common.ReturnValueIfNull(tosecObject.Description, ""));
|
||||
dbDict.Add("category", Common.ReturnValueIfNull(tosecObject.Category, ""));
|
||||
dbDict.Add("version", Common.ReturnValueIfNull(tosecObject.Version, ""));
|
||||
dbDict.Add("author", Common.ReturnValueIfNull(tosecObject.Author, ""));
|
||||
dbDict.Add("email", Common.ReturnValueIfNull(tosecObject.Email, ""));
|
||||
dbDict.Add("homepage", Common.ReturnValueIfNull(tosecObject.Homepage, ""));
|
||||
dbDict.Add("uri", Common.ReturnValueIfNull(tosecObject.Url, ""));
|
||||
dbDict.Add("sourcetype", Common.ReturnValueIfNull(tosecObject.SourceType, ""));
|
||||
dbDict.Add("sourcemd5", tosecObject.SourceMd5);
|
||||
dbDict.Add("sourcesha1", tosecObject.SourceSHA1);
|
||||
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
if (sigDB.Rows.Count == 0)
|
||||
{
|
||||
// entry not present, insert it
|
||||
sql = "INSERT INTO Signatures_Sources (Name, Description, Category, Version, Author, Email, Homepage, Url, SourceType, SourceMD5, sourceSHA1) VALUES (@name, @description, @category, @version, @author, @email, @homepage, @uri, @sourcetype, @sourcemd5, @sourcesha1)";
|
||||
|
||||
db.ExecuteCMD(sql, dbDict);
|
||||
|
||||
processGames = true;
|
||||
}
|
||||
|
||||
if (processGames == true)
|
||||
{
|
||||
for (int x = 0; x < tosecObject.Games.Count; ++x)
|
||||
{
|
||||
RomSignatureObject.Game gameObject = tosecObject.Games[x];
|
||||
|
||||
// update display
|
||||
if (showGames == true)
|
||||
{
|
||||
Console.SetCursorPosition(0, Console.CursorTop - 1);
|
||||
string statusGameOutput = " ==> " + (x + 1).ToString().PadLeft(7, ' ') + " / " + tosecObject.Games.Count.ToString().PadLeft(7, ' ') + " : " + gameObject.Name;
|
||||
Console.WriteLine("\r " + statusGameOutput.PadRight(lineGameNameLength, ' ') + "\r");
|
||||
lineGameNameLength = statusGameOutput.Length;
|
||||
}
|
||||
|
||||
// set up game dictionary
|
||||
dbDict = new Dictionary<string, object>();
|
||||
dbDict.Add("name", Common.ReturnValueIfNull(gameObject.Name, ""));
|
||||
dbDict.Add("description", Common.ReturnValueIfNull(gameObject.Description, ""));
|
||||
dbDict.Add("year", Common.ReturnValueIfNull(gameObject.Year, ""));
|
||||
dbDict.Add("publisher", Common.ReturnValueIfNull(gameObject.Publisher, ""));
|
||||
dbDict.Add("demo", (int)gameObject.Demo);
|
||||
dbDict.Add("system", Common.ReturnValueIfNull(gameObject.System, ""));
|
||||
dbDict.Add("platform", Common.ReturnValueIfNull(gameObject.System, ""));
|
||||
dbDict.Add("systemvariant", Common.ReturnValueIfNull(gameObject.SystemVariant, ""));
|
||||
dbDict.Add("video", Common.ReturnValueIfNull(gameObject.Video, ""));
|
||||
dbDict.Add("country", Common.ReturnValueIfNull(gameObject.Country, ""));
|
||||
dbDict.Add("language", Common.ReturnValueIfNull(gameObject.Language, ""));
|
||||
dbDict.Add("copyright", Common.ReturnValueIfNull(gameObject.Copyright, ""));
|
||||
|
||||
// store platform
|
||||
int gameSystem = 0;
|
||||
if (gameObject.System != null)
|
||||
{
|
||||
sql = "SELECT Id FROM Signatures_Platforms WHERE Platform=@platform";
|
||||
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
if (sigDB.Rows.Count == 0)
|
||||
{
|
||||
// entry not present, insert it
|
||||
sql = "INSERT INTO Signatures_Platforms (Platform) VALUES (@platform); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
|
||||
gameSystem = Convert.ToInt32(sigDB.Rows[0][0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameSystem = (int)sigDB.Rows[0][0];
|
||||
}
|
||||
}
|
||||
dbDict.Add("systemid", gameSystem);
|
||||
|
||||
// store publisher
|
||||
int gamePublisher = 0;
|
||||
if (gameObject.Publisher != null)
|
||||
{
|
||||
sql = "SELECT * FROM Signatures_Publishers WHERE Publisher=@publisher";
|
||||
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
if (sigDB.Rows.Count == 0)
|
||||
{
|
||||
// entry not present, insert it
|
||||
sql = "INSERT INTO Signatures_Publishers (Publisher) VALUES (@publisher); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
gamePublisher = Convert.ToInt32(sigDB.Rows[0][0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gamePublisher = (int)sigDB.Rows[0][0];
|
||||
}
|
||||
}
|
||||
dbDict.Add("publisherid", gamePublisher);
|
||||
|
||||
// store game
|
||||
int gameId = 0;
|
||||
sql = "SELECT * FROM Signatures_Games WHERE Name=@name AND Year=@year AND PublisherId=@publisher AND SystemId=@systemid AND Country=@country AND Language=@language";
|
||||
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
if (sigDB.Rows.Count == 0)
|
||||
{
|
||||
// entry not present, insert it
|
||||
sql = "INSERT INTO Signatures_Games " +
|
||||
"(Name, Description, Year, PublisherId, Demo, SystemId, SystemVariant, Video, Country, Language, Copyright) VALUES " +
|
||||
"(@name, @description, @year, @publisherid, @demo, @systemid, @systemvariant, @video, @country, @language, @copyright); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
|
||||
gameId = Convert.ToInt32(sigDB.Rows[0][0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameId = (int)sigDB.Rows[0][0];
|
||||
}
|
||||
|
||||
// store rom
|
||||
foreach (RomSignatureObject.Game.Rom romObject in gameObject.Roms)
|
||||
{
|
||||
if (romObject.Md5 != null)
|
||||
{
|
||||
int romId = 0;
|
||||
sql = "SELECT * FROM Signatures_Roms WHERE GameId=@gameid AND MD5=@md5";
|
||||
dbDict = new Dictionary<string, object>();
|
||||
dbDict.Add("gameid", gameId);
|
||||
dbDict.Add("name", Common.ReturnValueIfNull(romObject.Name, ""));
|
||||
dbDict.Add("size", Common.ReturnValueIfNull(romObject.Size, ""));
|
||||
dbDict.Add("crc", Common.ReturnValueIfNull(romObject.Crc, ""));
|
||||
dbDict.Add("md5", romObject.Md5);
|
||||
dbDict.Add("sha1", Common.ReturnValueIfNull(romObject.Sha1, ""));
|
||||
dbDict.Add("developmentstatus", Common.ReturnValueIfNull(romObject.DevelopmentStatus, ""));
|
||||
|
||||
if (romObject.flags != null)
|
||||
{
|
||||
if (romObject.flags.Count > 0)
|
||||
{
|
||||
dbDict.Add("flags", Newtonsoft.Json.JsonConvert.SerializeObject(romObject.flags));
|
||||
}
|
||||
else
|
||||
{
|
||||
dbDict.Add("flags", "[ ]");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbDict.Add("flags", "[ ]");
|
||||
}
|
||||
dbDict.Add("romtype", (int)romObject.RomType);
|
||||
dbDict.Add("romtypemedia", Common.ReturnValueIfNull(romObject.RomTypeMedia, ""));
|
||||
dbDict.Add("medialabel", Common.ReturnValueIfNull(romObject.MediaLabel, ""));
|
||||
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
if (sigDB.Rows.Count == 0)
|
||||
{
|
||||
// entry not present, insert it
|
||||
sql = "INSERT INTO Signatures_Roms (GameId, Name, Size, CRC, MD5, SHA1, DevelopmentStatus, Flags, RomType, RomTypeMedia, MediaLabel) VALUES (@gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @flags, @romtype, @romtypemedia, @medialabel); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||
sigDB = db.ExecuteCMD(sql, dbDict);
|
||||
|
||||
|
||||
romId = Convert.ToInt32(sigDB.Rows[0][0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
romId = (int)sigDB.Rows[0][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RootNamespace>gaseous_signature_ingestor</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\gaseous-romsignatureobject\gaseous-romsignatureobject.csproj" />
|
||||
<ProjectReference Include="..\gaseous-signature-parser\gaseous-signature-parser.csproj" />
|
||||
<ProjectReference Include="..\gaseous-tools\gaseous-tools.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MySql.Data" Version="8.1.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
|
||||
<StartAction>Project</StartAction>
|
||||
<StartArguments>-tosecpath ~/Downloads/TOSEC\ -\ DAT\ Pack\ -\ Complete\ \(3764\)\ \(TOSEC-v2023-01-23\)/TOSEC/</StartArguments>
|
||||
<ExternalConsole>true</ExternalConsole>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@@ -1,526 +0,0 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using gaseous_romsignatureobject;
|
||||
|
||||
namespace gaseous_signature_parser.parsers
|
||||
{
|
||||
public class TosecParser
|
||||
{
|
||||
public RomSignatureObject Parse(string XMLFile)
|
||||
{
|
||||
// load resources
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
// load systems list
|
||||
List<string> TOSECSystems = new List<string>();
|
||||
var resourceName = "gaseous_signature_parser.Support.Parsers.TOSEC.Systems.txt";
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
TOSECSystems = reader.ReadToEnd().Split(Environment.NewLine).ToList<string>();
|
||||
}
|
||||
// load video list
|
||||
List<string> TOSECVideo = new List<string>();
|
||||
resourceName = "gaseous_signature_parser.Support.Parsers.TOSEC.Video.txt";
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
TOSECVideo = reader.ReadToEnd().Split(Environment.NewLine).ToList<string>();
|
||||
}
|
||||
// load country list
|
||||
Dictionary<string, string> TOSECCountry = new Dictionary<string, string>();
|
||||
resourceName = "gaseous_signature_parser.Support.Parsers.TOSEC.Country.txt";
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
do
|
||||
{
|
||||
string[] line = reader.ReadLine().Split(",");
|
||||
TOSECCountry.Add(line[0], line[1]);
|
||||
} while (reader.EndOfStream == false);
|
||||
}
|
||||
// load language list
|
||||
Dictionary<string, string> TOSECLanguage = new Dictionary<string, string>();
|
||||
resourceName = "gaseous_signature_parser.Support.Parsers.TOSEC.Language.txt";
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
do
|
||||
{
|
||||
string[] line = reader.ReadLine().Split(",");
|
||||
TOSECLanguage.Add(line[0], line[1]);
|
||||
} while (reader.EndOfStream == false);
|
||||
}
|
||||
// load copyright list
|
||||
Dictionary<string, string> TOSECCopyright = new Dictionary<string, string>();
|
||||
resourceName = "gaseous_signature_parser.Support.Parsers.TOSEC.Copyright.txt";
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
do
|
||||
{
|
||||
string[] line = reader.ReadLine().Split(",");
|
||||
TOSECCopyright.Add(line[0], line[1]);
|
||||
} while (reader.EndOfStream == false);
|
||||
}
|
||||
// load development status list
|
||||
Dictionary<string, string> TOSECDevelopment = new Dictionary<string, string>();
|
||||
resourceName = "gaseous_signature_parser.Support.Parsers.TOSEC.DevelopmentStatus.txt";
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
do
|
||||
{
|
||||
string[] line = reader.ReadLine().Split(",");
|
||||
TOSECDevelopment.Add(line[0], line[1]);
|
||||
} while (reader.EndOfStream == false);
|
||||
}
|
||||
|
||||
// get hashes of TOSEC file
|
||||
var xmlStream = File.OpenRead(XMLFile);
|
||||
|
||||
var md5 = MD5.Create();
|
||||
byte[] md5HashByte = md5.ComputeHash(xmlStream);
|
||||
string md5Hash = BitConverter.ToString(md5HashByte).Replace("-", "").ToLowerInvariant();
|
||||
|
||||
var sha1 = SHA1.Create();
|
||||
byte[] sha1HashByte = sha1.ComputeHash(xmlStream);
|
||||
string sha1Hash = BitConverter.ToString(sha1HashByte).Replace("-", "").ToLowerInvariant();
|
||||
|
||||
// load TOSEC file
|
||||
XmlDocument tosecXmlDoc = new XmlDocument();
|
||||
tosecXmlDoc.Load(XMLFile);
|
||||
|
||||
RomSignatureObject tosecObject = new RomSignatureObject();
|
||||
|
||||
// get header
|
||||
XmlNode xmlHeader = tosecXmlDoc.DocumentElement.SelectSingleNode("/datafile/header");
|
||||
tosecObject.SourceType = "TOSEC";
|
||||
tosecObject.SourceMd5 = md5Hash;
|
||||
tosecObject.SourceSHA1 = sha1Hash;
|
||||
foreach (XmlNode childNode in xmlHeader.ChildNodes)
|
||||
{
|
||||
switch (childNode.Name.ToLower())
|
||||
{
|
||||
case "name":
|
||||
tosecObject.Name = childNode.InnerText;
|
||||
break;
|
||||
|
||||
case "description":
|
||||
tosecObject.Description = childNode.InnerText;
|
||||
break;
|
||||
|
||||
case "category":
|
||||
tosecObject.Category = childNode.InnerText;
|
||||
break;
|
||||
|
||||
case "version":
|
||||
tosecObject.Version = childNode.InnerText;
|
||||
break;
|
||||
|
||||
case "author":
|
||||
tosecObject.Author = childNode.InnerText;
|
||||
break;
|
||||
|
||||
case "email":
|
||||
tosecObject.Email = childNode.InnerText;
|
||||
break;
|
||||
|
||||
case "homepage":
|
||||
tosecObject.Homepage = childNode.InnerText;
|
||||
break;
|
||||
|
||||
case "url":
|
||||
try
|
||||
{
|
||||
tosecObject.Url = new Uri(childNode.InnerText);
|
||||
}
|
||||
catch
|
||||
{
|
||||
tosecObject.Url = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// get games
|
||||
tosecObject.Games = new List<RomSignatureObject.Game>();
|
||||
XmlNodeList xmlGames = tosecXmlDoc.DocumentElement.SelectNodes("/datafile/game");
|
||||
foreach (XmlNode xmlGame in xmlGames)
|
||||
{
|
||||
RomSignatureObject.Game gameObject = new RomSignatureObject.Game();
|
||||
|
||||
// parse game name
|
||||
string[] gameNameTitleParts = xmlGame.Attributes["name"].Value.Split("[");
|
||||
string gameName = gameNameTitleParts[0];
|
||||
|
||||
// before split, save and remove the demo tag if present
|
||||
if (gameName.Contains("(demo) ", StringComparison.CurrentCulture))
|
||||
{
|
||||
gameObject.Demo = RomSignatureObject.Game.DemoTypes.demo;
|
||||
gameName = gameName.Replace("(demo) ", "");
|
||||
}
|
||||
else if (gameName.Contains("(demo-kiosk) ", StringComparison.CurrentCulture))
|
||||
{
|
||||
gameObject.Demo = RomSignatureObject.Game.DemoTypes.demo_kiosk;
|
||||
gameName = gameName.Replace("(demo-kiosk) ", "");
|
||||
}
|
||||
else if (gameName.Contains("(demo-playable) ", StringComparison.CurrentCulture))
|
||||
{
|
||||
gameObject.Demo = RomSignatureObject.Game.DemoTypes.demo_playable;
|
||||
gameName = gameName.Replace("(demo-playable) ", "");
|
||||
}
|
||||
else if (gameName.Contains("(demo-rolling) ", StringComparison.CurrentCulture))
|
||||
{
|
||||
gameObject.Demo = RomSignatureObject.Game.DemoTypes.demo_rolling;
|
||||
gameName = gameName.Replace("(demo-rolling) ", "");
|
||||
}
|
||||
else if (gameName.Contains("(demo-slideshow) ", StringComparison.CurrentCulture))
|
||||
{
|
||||
gameObject.Demo = RomSignatureObject.Game.DemoTypes.demo_slideshow;
|
||||
gameName = gameName.Replace("(demo-slideshow) ", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.Demo = RomSignatureObject.Game.DemoTypes.NotDemo;
|
||||
}
|
||||
|
||||
string[] gameNameTokens = gameName.Split("(");
|
||||
// game title should be first item
|
||||
gameObject.Name = gameNameTokens[0].Trim();
|
||||
|
||||
// game year should be second item
|
||||
if (gameNameTokens.Length >= 2)
|
||||
{
|
||||
bool dateFound = false;
|
||||
|
||||
// verify the value
|
||||
string dateToken = gameNameTokens[1].Replace(")", "");
|
||||
if (dateToken.Length >= 4)
|
||||
{
|
||||
// test for possible year values
|
||||
// first up - centuries
|
||||
if (dateToken == "19xx" || dateToken == "20xx")
|
||||
{
|
||||
// date is a century
|
||||
gameObject.Year = dateToken;
|
||||
dateFound = true;
|
||||
} else
|
||||
{
|
||||
// check for decades
|
||||
for (UInt16 i = 0; i < 10; i++)
|
||||
{
|
||||
if (dateToken == "19" + i + "x" || dateToken == "20" + i + "x")
|
||||
{
|
||||
// date is a decade
|
||||
gameObject.Year = dateToken;
|
||||
dateFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dateFound == false)
|
||||
{
|
||||
// check if the year is a four digit number
|
||||
DateTime dateTime = new DateTime();
|
||||
if (DateTime.TryParse(string.Format("1/1/{0}", dateToken), out dateTime))
|
||||
{
|
||||
// is a valid year!
|
||||
gameObject.Year = dateToken;
|
||||
dateFound = true;
|
||||
}
|
||||
|
||||
// if we still haven't found a valid date, check if the whole string is a valid date object
|
||||
if (dateFound == false)
|
||||
{
|
||||
if (DateTime.TryParse(dateToken, out dateTime))
|
||||
{
|
||||
// is a valid year!
|
||||
gameObject.Year = dateToken;
|
||||
dateFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
// if we still haven't found a valid date, check if the whole string is a valid date object, but with x's
|
||||
// example: 19xx-12-2x
|
||||
if (dateFound == false)
|
||||
{
|
||||
if (DateTime.TryParse(dateToken.Replace("x", "0"), out dateTime))
|
||||
{
|
||||
// is a valid year!
|
||||
gameObject.Year = dateToken;
|
||||
dateFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
// if we still haven't found a valid date, perhaps it a year and month?
|
||||
// example: 19xx-12
|
||||
if (dateFound == false)
|
||||
{
|
||||
if (DateTime.TryParse(dateToken.Replace("x", "0") + "-01", out dateTime))
|
||||
{
|
||||
// is a valid year!
|
||||
gameObject.Year = dateToken;
|
||||
dateFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.Year = "";
|
||||
}
|
||||
// game publisher should be third item
|
||||
if (gameNameTokens.Length >= 3)
|
||||
{
|
||||
gameObject.Publisher = gameNameTokens[2].Replace(")", "").Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.Publisher = "";
|
||||
}
|
||||
// process remaining tokens
|
||||
// set default values
|
||||
gameObject.System = tosecObject.Name.Split(" - ")[0];
|
||||
// process title values
|
||||
UInt16 StartToken = 0;
|
||||
foreach (string rawToken in gameNameTokens)
|
||||
{
|
||||
if (StartToken > 2)
|
||||
{
|
||||
string[] tokenSplit = rawToken.Split("[");
|
||||
|
||||
// replace the extra closing bracket
|
||||
string token = tokenSplit[0].Replace(")", "").Trim();
|
||||
|
||||
// perform tests on the token to see what it is
|
||||
// exclude strings that start with [ in this part
|
||||
if (!(token.StartsWith("[") && token.EndsWith("]")))
|
||||
{
|
||||
// check for systems
|
||||
if (TOSECSystems.Contains(token, StringComparer.CurrentCulture))
|
||||
{
|
||||
// this is a system token
|
||||
gameObject.SystemVariant = token;
|
||||
}
|
||||
|
||||
// check for video
|
||||
if (TOSECVideo.Contains(token, StringComparer.CurrentCulture))
|
||||
{
|
||||
// this is a system token
|
||||
gameObject.Video = token;
|
||||
}
|
||||
|
||||
// check for country
|
||||
if (TOSECCountry.ContainsKey(token))
|
||||
{
|
||||
gameObject.Country = token;
|
||||
}
|
||||
|
||||
// check for language
|
||||
if (TOSECLanguage.ContainsKey(token))
|
||||
{
|
||||
gameObject.Language = token;
|
||||
}
|
||||
|
||||
// check for copyright
|
||||
if (TOSECCopyright.ContainsKey(token))
|
||||
{
|
||||
gameObject.Copyright = token;
|
||||
}
|
||||
}
|
||||
}
|
||||
StartToken += 1;
|
||||
}
|
||||
|
||||
gameObject.Roms = new List<RomSignatureObject.Game.Rom>();
|
||||
|
||||
// get the roms
|
||||
string romDescription = "";
|
||||
foreach (XmlNode xmlGameDetail in xmlGame.ChildNodes)
|
||||
{
|
||||
switch (xmlGameDetail.Name.ToLower())
|
||||
{
|
||||
case "description":
|
||||
romDescription = xmlGameDetail.InnerText;
|
||||
break;
|
||||
|
||||
case "rom":
|
||||
RomSignatureObject.Game.Rom romObject = new RomSignatureObject.Game.Rom();
|
||||
if (xmlGameDetail != null)
|
||||
{
|
||||
romObject.Name = xmlGameDetail.Attributes["name"]?.Value;
|
||||
if (xmlGameDetail.Attributes["size"]?.Value != null)
|
||||
{
|
||||
romObject.Size = UInt64.Parse(xmlGameDetail.Attributes["size"]?.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
romObject.Size = 0;
|
||||
}
|
||||
romObject.Crc = xmlGameDetail.Attributes["crc"]?.Value;
|
||||
romObject.Md5 = xmlGameDetail.Attributes["md5"]?.Value;
|
||||
romObject.Sha1 = xmlGameDetail.Attributes["sha1"]?.Value;
|
||||
romObject.SignatureSource = RomSignatureObject.Game.Rom.SignatureSourceType.TOSEC;
|
||||
|
||||
// parse name
|
||||
string[] romNameTokens = romDescription.Split("(");
|
||||
foreach (string rawToken in romNameTokens)
|
||||
{
|
||||
string[] tokenSplit = rawToken.Split("[");
|
||||
|
||||
// replace the extra closing bracket
|
||||
string token = tokenSplit[0].Replace(")", "").Trim();
|
||||
|
||||
// check for copyright
|
||||
if (TOSECDevelopment.ContainsKey(token))
|
||||
{
|
||||
romObject.DevelopmentStatus = token;
|
||||
}
|
||||
|
||||
// check for media type
|
||||
if (token.StartsWith("Disc") ||
|
||||
token.StartsWith("Disk") ||
|
||||
token.StartsWith("File") ||
|
||||
token.StartsWith("Part") ||
|
||||
token.StartsWith("Side") ||
|
||||
token.StartsWith("Tape"))
|
||||
{
|
||||
string[] tokens = token.Split(" ");
|
||||
switch (tokens[0])
|
||||
{
|
||||
case "Disc":
|
||||
romObject.RomType = RomSignatureObject.Game.Rom.RomTypes.Disc;
|
||||
break;
|
||||
case "Disk":
|
||||
romObject.RomType = RomSignatureObject.Game.Rom.RomTypes.Disk;
|
||||
break;
|
||||
case "File":
|
||||
romObject.RomType = RomSignatureObject.Game.Rom.RomTypes.File;
|
||||
break;
|
||||
case "Part":
|
||||
romObject.RomType = RomSignatureObject.Game.Rom.RomTypes.Part;
|
||||
break;
|
||||
case "Side":
|
||||
romObject.RomType = RomSignatureObject.Game.Rom.RomTypes.Side;
|
||||
break;
|
||||
case "Tape":
|
||||
romObject.RomType = RomSignatureObject.Game.Rom.RomTypes.Tape;
|
||||
break;
|
||||
}
|
||||
romObject.RomTypeMedia = token;
|
||||
}
|
||||
|
||||
// check for media label
|
||||
if (token.Length > 0 &&
|
||||
(token + ")") == gameNameTokens.Last() &&
|
||||
(
|
||||
token != romObject.RomTypeMedia &&
|
||||
token != gameObject.Publisher &&
|
||||
token != gameObject.SystemVariant &&
|
||||
token != gameObject.Video &&
|
||||
token != gameObject.Country &&
|
||||
token != gameObject.Copyright &&
|
||||
token != gameObject.Language &&
|
||||
token != romObject.DevelopmentStatus
|
||||
)
|
||||
)
|
||||
{
|
||||
// likely the media label?
|
||||
romObject.MediaLabel = token;
|
||||
}
|
||||
|
||||
// process dump flags
|
||||
if (rawToken.IndexOf("[") > 0)
|
||||
{
|
||||
// has dump flags
|
||||
string rawDumpFlags = rawToken.Substring(rawToken.IndexOf("["));
|
||||
string[] dumpFlags = rawDumpFlags.Split("[");
|
||||
foreach (string dumpFlag in dumpFlags)
|
||||
{
|
||||
string dToken = dumpFlag.Replace("]", "");
|
||||
if (dToken.Length > 0)
|
||||
{
|
||||
string[] dTokenCompare = dToken.Split(" ");
|
||||
if (dTokenCompare[0].Trim().ToLower().StartsWith("a"))
|
||||
{
|
||||
romObject.flags.Add(dTokenCompare[0].Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
switch (dTokenCompare[0].Trim().ToLower())
|
||||
{
|
||||
case "cr":
|
||||
// cracked
|
||||
case "f":
|
||||
// fixed
|
||||
case "h":
|
||||
// hacked
|
||||
case "m":
|
||||
// modified
|
||||
case "p":
|
||||
// pirated
|
||||
case "t":
|
||||
// trained
|
||||
case "tr":
|
||||
// translated
|
||||
case "o":
|
||||
// overdump
|
||||
case "u":
|
||||
// underdump
|
||||
case "v":
|
||||
// virus
|
||||
case "b":
|
||||
// bad dump
|
||||
case "a":
|
||||
// alternate
|
||||
case "!":
|
||||
// known verified dump
|
||||
// -------------------
|
||||
romObject.flags.Add(dToken);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gameObject.Roms.Add(romObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// search for existing gameObject to update
|
||||
bool existingGameFound = false;
|
||||
foreach (RomSignatureObject.Game existingGame in tosecObject.Games)
|
||||
{
|
||||
if (existingGame.Name == gameObject.Name &&
|
||||
existingGame.Year == gameObject.Year &&
|
||||
existingGame.Publisher == gameObject.Publisher &&
|
||||
existingGame.Country == gameObject.Country &&
|
||||
existingGame.Language == gameObject.Language)
|
||||
{
|
||||
existingGame.Roms.AddRange(gameObject.Roms);
|
||||
existingGameFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (existingGameFound == false)
|
||||
{
|
||||
tosecObject.Games.Add(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
return tosecObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +0,0 @@
|
||||
CW,Cardware
|
||||
CW-R,Cardware-Registered
|
||||
FW,Freeware
|
||||
GW,Giftware
|
||||
GW-R,Giftware-Registered
|
||||
LW,Licenceware
|
||||
PD,Public Domain
|
||||
SW,Shareware
|
||||
SW-R,Shareware-Registered
|
@@ -1,68 +0,0 @@
|
||||
AE,United Arab Emirates
|
||||
AL,Albania
|
||||
AS,Asia
|
||||
AT,Austria
|
||||
AU,Australia
|
||||
BA,Bosnia and Herzegovina
|
||||
BE,Belgium
|
||||
BG,Bulgaria
|
||||
BR,Brazil
|
||||
CA,Canada
|
||||
CH,Switzerland
|
||||
CL,Chile
|
||||
CN,China
|
||||
CS,Serbia and Montenegro
|
||||
CY,Cyprus
|
||||
CZ,Czech Republic
|
||||
DE,Germany
|
||||
DK,Denmark
|
||||
EE,Estonia
|
||||
EG,Egypt
|
||||
ES,Spain
|
||||
EU,Europe
|
||||
FI,Finland
|
||||
FR,France
|
||||
GB,United Kingdom
|
||||
GR,Greece
|
||||
HK,Hong Kong
|
||||
HR,Croatia
|
||||
HU,Hungary
|
||||
ID,Indonesia
|
||||
IE,Ireland
|
||||
IL,Israel
|
||||
IN,India
|
||||
IR,Iran
|
||||
IS,Iceland
|
||||
IT,Italy
|
||||
JO,Jordan
|
||||
JP,Japan
|
||||
KR,South Korea
|
||||
LT,Lithuania
|
||||
LU,Luxembourg
|
||||
LV,Latvia
|
||||
MN,Mongolia
|
||||
MX,Mexico
|
||||
MY,Malaysia
|
||||
NL,Netherlands
|
||||
NO,Norway
|
||||
NP,Nepal
|
||||
NZ,New Zealand
|
||||
OM,Oman
|
||||
PE,Peru
|
||||
PH,Philippines
|
||||
PL,Poland
|
||||
PT,Portugal
|
||||
QA,Qatar
|
||||
RO,Romania
|
||||
RU,Russia
|
||||
SE,Sweden
|
||||
SG,Singapore
|
||||
SI,Slovenia
|
||||
SK,Slovakia
|
||||
TH,Thailand
|
||||
TR,Turkey
|
||||
TW,Taiwan
|
||||
US,United States
|
||||
VN,Vietnam
|
||||
YU,Yugoslavia
|
||||
ZA,South Africa
|
@@ -1,5 +0,0 @@
|
||||
alpha,Early test build
|
||||
beta,Later; feature complete test build
|
||||
preview,Near complete build
|
||||
pre-release,Near complete build
|
||||
proto,Unreleased; prototype software
|
@@ -1,45 +0,0 @@
|
||||
ar,Arabic
|
||||
bg,Bulgarian
|
||||
bs,Bosnian
|
||||
cs,Czech
|
||||
cy,Welsh
|
||||
da,Danish
|
||||
de,German
|
||||
el,Greek
|
||||
en,English
|
||||
eo,Esperanto
|
||||
es,Spanish
|
||||
et,Estonian
|
||||
fa,Persian
|
||||
fi,Finnish
|
||||
fr,French
|
||||
ga,Irish
|
||||
gu,Gujarati
|
||||
he,Hebrew
|
||||
hi,Hindi
|
||||
hr,Croatian
|
||||
hu,Hungarian
|
||||
is,Icelandic
|
||||
it,Italian
|
||||
ja,Japanese
|
||||
ko,Korean
|
||||
lt,Lithuanian
|
||||
lv,Latvian
|
||||
ms,Malay
|
||||
nl,Dutch
|
||||
no,Norwegian
|
||||
pl,Polish
|
||||
pt,Portuguese
|
||||
ro,Romanian
|
||||
ru,Russian
|
||||
sk,Slovakian
|
||||
sl,Slovenian
|
||||
sq,Albanian
|
||||
sr,Serbian
|
||||
sv,Swedish
|
||||
th,Thai
|
||||
tr,Turkish
|
||||
ur,Urdu
|
||||
vi,Vietnamese
|
||||
yi,Yiddish
|
||||
zh,Chinese
|
@@ -1,57 +0,0 @@
|
||||
+2
|
||||
+2a
|
||||
+3
|
||||
130XE
|
||||
A1000
|
||||
A1200
|
||||
A1200-A4000
|
||||
A2000
|
||||
A2000-A3000
|
||||
A2024
|
||||
A2500-A3000UX
|
||||
A3000
|
||||
A4000
|
||||
A4000T
|
||||
A500
|
||||
A500+
|
||||
A500-A1000-A2000
|
||||
A500-A1000-A2000-CDTV
|
||||
A500-A1200
|
||||
A500-A1200-A2000-A4000
|
||||
A500-A2000
|
||||
A500-A600-A2000
|
||||
A570
|
||||
A600
|
||||
A600HD
|
||||
AGA
|
||||
AGA-CD32
|
||||
Aladdin Deck Enhancer
|
||||
CD32
|
||||
CDTV
|
||||
Computrainer
|
||||
Doctor PC Jr.
|
||||
ECS
|
||||
ECS-AGA
|
||||
Executive
|
||||
Mega ST
|
||||
Mega-STE
|
||||
OCS
|
||||
OCS-AGA
|
||||
ORCH80
|
||||
Osbourne 1
|
||||
PIANO90
|
||||
PlayChoice-10
|
||||
Plus4
|
||||
Primo-A
|
||||
Primo-A64
|
||||
Primo-B
|
||||
Primo-B64
|
||||
Pro-Primo
|
||||
ST
|
||||
STE
|
||||
STE-Falcon
|
||||
TT
|
||||
TURBO-R GT
|
||||
TURBO-R ST
|
||||
VS DualSystem
|
||||
VS UniSystem
|
@@ -1,13 +0,0 @@
|
||||
CGA
|
||||
EGA
|
||||
HGC
|
||||
MCGA
|
||||
MDA
|
||||
NTSC
|
||||
NTSC-PAL
|
||||
PAL
|
||||
PAL-60
|
||||
PAL-NTSC
|
||||
SVGA
|
||||
VGA
|
||||
XGA
|
@@ -1,38 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RootNamespace>gaseous_signature_parser</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Support\Parsers\TOSEC\Copyright.txt" />
|
||||
<None Remove="Support\Parsers\TOSEC\Country.txt" />
|
||||
<None Remove="Support\Parsers\TOSEC\DevelopmentStatus.txt" />
|
||||
<None Remove="Support\Parsers\TOSEC\Language.txt" />
|
||||
<None Remove="Support\Parsers\TOSEC\Systems.txt" />
|
||||
<None Remove="Support\Parsers\TOSEC\Video.txt" />
|
||||
<None Remove="Support\" />
|
||||
<None Remove="Classes\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Support\Parsers\TOSEC\Copyright.txt" />
|
||||
<EmbeddedResource Include="Support\Parsers\TOSEC\Country.txt" />
|
||||
<EmbeddedResource Include="Support\Parsers\TOSEC\DevelopmentStatus.txt" />
|
||||
<EmbeddedResource Include="Support\Parsers\TOSEC\Language.txt" />
|
||||
<EmbeddedResource Include="Support\Parsers\TOSEC\Systems.txt" />
|
||||
<EmbeddedResource Include="Support\Parsers\TOSEC\Video.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Support\" />
|
||||
<Folder Include="Classes\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\gaseous-romsignatureobject\gaseous-romsignatureobject.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user