Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TheGamesDb.net as a DataHandler #13

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
16 changes: 11 additions & 5 deletions other/GameFinder.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
using GameCollector.StoreHandlers.WargamingNet;
using GameCollector.EmuHandlers.Dolphin;
using GameCollector.EmuHandlers.MAME;
//using GameCollector.DataHandlers.TheGamesDb;
using GameCollector.DataHandlers.TheGamesDb;
using Microsoft.Extensions.Logging;
using NexusMods.Paths;
using NLog;
Expand Down Expand Up @@ -145,7 +145,7 @@ private async static void Run(Options options, ILogger logger)
options.RobotCache = true;
options.Rockstar = true;
options.Steam = true;
//options.TheGamesDB = true;
options.TheGamesDB = true;
options.Ubisoft = true;
options.Wargaming = true;
options.Xbox = true;
Expand Down Expand Up @@ -259,7 +259,7 @@ private async static void Run(Options options, ILogger logger)
RunSteamHandler(realFileSystem, registry: null, options.SteamAPI, i, p);
}

//if (options.TheGamesDB) tasks.Add(Task.Run(() => RunTheGamesDbHandler(realFileSystem, options.TheGamesDBAPI, i, p), cancelToken));
if (options.TheGamesDB) tasks.Add(Task.Run(() => RunTheGamesDbHandler(realFileSystem, options.TheGamesDBAPI, i, p), cancelToken));

Task.WaitAll(tasks.ToArray(), cancelToken);

Expand All @@ -271,6 +271,14 @@ private async static void Run(Options options, ILogger logger)
await Task.WhenAll(tasks).ConfigureAwait(false);
*/

/*
Parallel.ForEach(tasks, task =>
{
task.Start();
});
await Task.WhenAll(tasks).ConfigureAwait(false);
*/

logger.LogInformation($"{nameof(Program)} complete");
}

Expand Down Expand Up @@ -464,15 +472,13 @@ private static void RunMAMEHandler(IFileSystem fileSystem, AbsolutePath path, bo
LogGamesAndErrors(handler.FindAllGames(installed, baseOnly), logger);
}

/*
private static async void RunTheGamesDbHandler(IFileSystem fileSystem, string? tgdbApi, bool installed = false, bool baseOnly = false)
{
var logger = _provider.CreateLogger(nameof(TheGamesDbHandler));
//var handler = new TheGamesDbHandler(fileSystem, tgdbApi, registry: null, logger);
var handler = new TheGamesDbHandler(fileSystem, registry: null, logger);
LogGamesAndErrors(handler.FindAllGames(installed, baseOnly), logger);
}
*/

private static List<AWinePrefix> LogWinePrefixes<TWinePrefix>(IWinePrefixManager<TWinePrefix> prefixManager, ILogger logger)
where TWinePrefix : AWinePrefix
Expand Down
32 changes: 32 additions & 0 deletions src/GameCollector.DataHandlers.TheGamesDb/Companies.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace GameCollector.DataHandlers.TheGamesDb;

internal record Companies
{
public ushort? Code { get; set; }
public string? Status { get; set; }
public CompanyData? Data { get; set; }
[property: JsonPropertyName("remaining_monthly_allowance")]
public ushort? RemainingMonthlyAllowance { get; set; }
[property: JsonPropertyName("extra_allowance")]
public ushort? ExtraAllowance { get; set; }
[property: JsonPropertyName("allowance_refresh_timer")]
public ulong? AllowanceRefreshTimer { get; set; }
//public Pages? Pages { get; set; }
}

internal record CompanyData
{
public uint? Count { get; set; }
public Dictionary<uint, Company>? Developers { get; set; }
public Dictionary<uint, Company>? Publishers { get; set; }
public Include? Include { get; set; }
}

internal record Company
{
public ulong? Id { get; set; }
public string? Name { get; set; }
}
Loading
Loading