Compare commits
No commits in common. "adc067d8a2ca5468ce2364941e63cab5e914ba39" and "3bee1a5508cb59fbd38f3d2333f1f538b891137c" have entirely different histories.
adc067d8a2
...
3bee1a5508
@ -6,7 +6,6 @@ using System.Linq;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
|
||||||
using GoldbergGUI.Core.Models;
|
using GoldbergGUI.Core.Models;
|
||||||
using GoldbergGUI.Core.Utils;
|
using GoldbergGUI.Core.Utils;
|
||||||
using MvvmCross.Logging;
|
using MvvmCross.Logging;
|
||||||
@ -46,9 +45,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
private readonly string _accountNamePath = Path.Combine(GlobalSettingsPath, "settings/account_name.txt");
|
private readonly string _accountNamePath = Path.Combine(GlobalSettingsPath, "settings/account_name.txt");
|
||||||
private readonly string _userSteamIdPath = Path.Combine(GlobalSettingsPath, "settings/user_steam_id.txt");
|
private readonly string _userSteamIdPath = Path.Combine(GlobalSettingsPath, "settings/user_steam_id.txt");
|
||||||
private readonly string _languagePath = Path.Combine(GlobalSettingsPath, "settings/language.txt");
|
private readonly string _languagePath = Path.Combine(GlobalSettingsPath, "settings/language.txt");
|
||||||
|
private readonly string _customBroadcastIpsPath = Path.Combine(GlobalSettingsPath, "settings/custom_broadcasts.txt");
|
||||||
private readonly string _customBroadcastIpsPath =
|
|
||||||
Path.Combine(GlobalSettingsPath, "settings/custom_broadcasts.txt");
|
|
||||||
|
|
||||||
// ReSharper disable StringLiteralTypo
|
// ReSharper disable StringLiteralTypo
|
||||||
private readonly List<string> _interfaceNames = new List<string>
|
private readonly List<string> _interfaceNames = new List<string>
|
||||||
@ -86,11 +83,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
_log = log;
|
_log = log;
|
||||||
|
|
||||||
var download = await Download().ConfigureAwait(false);
|
var download = await Download().ConfigureAwait(false);
|
||||||
if (download)
|
if (download) await Extract(_goldbergZipPath).ConfigureAwait(false);
|
||||||
{
|
|
||||||
await Extract(_goldbergZipPath).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await GetGlobalSettings().ConfigureAwait(false);
|
return await GetGlobalSettings().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,16 +102,13 @@ namespace GoldbergGUI.Core.Services
|
|||||||
!long.TryParse(File.ReadLines(_userSteamIdPath).First().Trim(), out steamId) &&
|
!long.TryParse(File.ReadLines(_userSteamIdPath).First().Trim(), out steamId) &&
|
||||||
steamId < 76561197960265729 && steamId > 76561202255233023)
|
steamId < 76561197960265729 && steamId > 76561202255233023)
|
||||||
{
|
{
|
||||||
_log.Error("Invalid User Steam ID! Using default Steam ID...");
|
_log.Error("Invalid User Steam ID!");
|
||||||
steamId = DefaultSteamId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(_languagePath)) language = File.ReadLines(_languagePath).First().Trim();
|
if (File.Exists(_languagePath)) language = File.ReadLines(_languagePath).First().Trim();
|
||||||
if (File.Exists(_customBroadcastIpsPath))
|
if (File.Exists(_customBroadcastIpsPath))
|
||||||
customBroadcastIps.AddRange(
|
customBroadcastIps.AddRange(
|
||||||
File.ReadLines(_customBroadcastIpsPath).Select(line => line.Trim()));
|
File.ReadLines(_customBroadcastIpsPath).Select(line => line.Trim()));
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
_log.Info("Got global settings.");
|
|
||||||
return new GoldbergGlobalConfiguration
|
return new GoldbergGlobalConfiguration
|
||||||
{
|
{
|
||||||
AccountName = accountName,
|
AccountName = accountName,
|
||||||
@ -150,7 +140,6 @@ namespace GoldbergGUI.Core.Services
|
|||||||
await File.Create(_accountNamePath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_accountNamePath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_accountNamePath, DefaultAccountName).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_accountNamePath, DefaultAccountName).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// User SteamID
|
// User SteamID
|
||||||
if (userSteamId >= 76561197960265729 && userSteamId <= 76561202255233023)
|
if (userSteamId >= 76561197960265729 && userSteamId <= 76561202255233023)
|
||||||
{
|
{
|
||||||
@ -166,7 +155,6 @@ namespace GoldbergGUI.Core.Services
|
|||||||
await File.Create(_userSteamIdPath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_userSteamIdPath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_userSteamIdPath, DefaultSteamId.ToString()).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_userSteamIdPath, DefaultSteamId.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
if (!string.IsNullOrEmpty(language))
|
if (!string.IsNullOrEmpty(language))
|
||||||
{
|
{
|
||||||
@ -182,7 +170,6 @@ namespace GoldbergGUI.Core.Services
|
|||||||
await File.Create(_languagePath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_languagePath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_languagePath, DefaultLanguage).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_languagePath, DefaultLanguage).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom Broadcast IPs
|
// Custom Broadcast IPs
|
||||||
if (customBroadcastIps != null && customBroadcastIps.Count > 0)
|
if (customBroadcastIps != null && customBroadcastIps.Count > 0)
|
||||||
{
|
{
|
||||||
@ -198,7 +185,6 @@ namespace GoldbergGUI.Core.Services
|
|||||||
_log.Info("Empty list of custom broadcast IPs! Skipping...");
|
_log.Info("Empty list of custom broadcast IPs! Skipping...");
|
||||||
await Task.Run(() => File.Delete(_customBroadcastIpsPath)).ConfigureAwait(false);
|
await Task.Run(() => File.Delete(_customBroadcastIpsPath)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
_log.Info("Setting global configuration finished.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If first time, call GenerateInterfaces
|
// If first time, call GenerateInterfaces
|
||||||
@ -282,8 +268,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create steam_appid.txt
|
// create steam_appid.txt
|
||||||
await File.WriteAllTextAsync(Path.Combine(path, "steam_appid.txt"), c.AppId.ToString())
|
await File.WriteAllTextAsync(Path.Combine(path, "steam_appid.txt"), c.AppId.ToString()).ConfigureAwait(false);
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
// DLC
|
// DLC
|
||||||
if (c.DlcList.Count > 0)
|
if (c.DlcList.Count > 0)
|
||||||
@ -375,24 +360,16 @@ namespace GoldbergGUI.Core.Services
|
|||||||
var match = regex.Match(body);
|
var match = regex.Match(body);
|
||||||
if (File.Exists(jobIdPath))
|
if (File.Exists(jobIdPath))
|
||||||
{
|
{
|
||||||
try
|
_log.Info("Check if update is needed...");
|
||||||
|
var jobIdLocal = Convert.ToInt32(File.ReadLines(jobIdPath).First().Trim());
|
||||||
|
var jobIdRemote = Convert.ToInt32(match.Groups["jobid"].Value);
|
||||||
|
_log.Debug($"job_id: local {jobIdLocal}; remote {jobIdRemote}");
|
||||||
|
if (jobIdLocal.Equals(jobIdRemote))
|
||||||
{
|
{
|
||||||
_log.Info("Check if update is needed...");
|
_log.Info("Latest Goldberg emulator is already available! Skipping...");
|
||||||
var jobIdLocal = Convert.ToInt32(File.ReadLines(jobIdPath).First().Trim());
|
return false;
|
||||||
var jobIdRemote = Convert.ToInt32(match.Groups["jobid"].Value);
|
|
||||||
_log.Debug($"job_id: local {jobIdLocal}; remote {jobIdRemote}");
|
|
||||||
if (jobIdLocal.Equals(jobIdRemote))
|
|
||||||
{
|
|
||||||
_log.Info("Latest Goldberg emulator is already available! Skipping...");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
_log.Error("An error occured, local Goldberg setup might be broken!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.Info("Starting download...");
|
_log.Info("Starting download...");
|
||||||
await StartDownload(match.Value).ConfigureAwait(false);
|
await StartDownload(match.Value).ConfigureAwait(false);
|
||||||
return true;
|
return true;
|
||||||
@ -400,35 +377,15 @@ namespace GoldbergGUI.Core.Services
|
|||||||
|
|
||||||
private async Task StartDownload(string downloadUrl)
|
private async Task StartDownload(string downloadUrl)
|
||||||
{
|
{
|
||||||
try
|
var client = new HttpClient();
|
||||||
|
_log.Debug(downloadUrl);
|
||||||
|
await using var fileStream = File.OpenWrite(_goldbergZipPath);
|
||||||
|
//client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead)
|
||||||
|
var task = client.GetFileAsync(downloadUrl, fileStream).ConfigureAwait(false);
|
||||||
|
await task;
|
||||||
|
if (task.GetAwaiter().IsCompleted)
|
||||||
{
|
{
|
||||||
var client = new HttpClient();
|
_log.Info("Download finished!");
|
||||||
_log.Debug(downloadUrl);
|
|
||||||
await using var fileStream = File.OpenWrite(_goldbergZipPath);
|
|
||||||
//client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead)
|
|
||||||
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Head, downloadUrl);
|
|
||||||
var headResponse = await client.SendAsync(httpRequestMessage).ConfigureAwait(false);
|
|
||||||
var contentLength = headResponse.Content.Headers.ContentLength;
|
|
||||||
await client.GetFileAsync(downloadUrl, fileStream).ContinueWith(async t =>
|
|
||||||
{
|
|
||||||
await fileStream.DisposeAsync().ConfigureAwait(false);
|
|
||||||
var fileLength = new FileInfo(_goldbergZipPath).Length;
|
|
||||||
// Environment.Exit(128);
|
|
||||||
if (contentLength == fileLength)
|
|
||||||
{
|
|
||||||
_log.Info("Download finished!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("File size does not match!");
|
|
||||||
}
|
|
||||||
}).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
ShowErrorMessage();
|
|
||||||
_log.Error(e.ToString);
|
|
||||||
Environment.Exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,56 +393,13 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// Extract all from archive to subfolder ./goldberg/
|
// Extract all from archive to subfolder ./goldberg/
|
||||||
private async Task Extract(string archivePath)
|
private async Task Extract(string archivePath)
|
||||||
{
|
{
|
||||||
var errorOccured = false;
|
|
||||||
_log.Debug("Start extraction...");
|
_log.Debug("Start extraction...");
|
||||||
Directory.Delete(_goldbergPath, true);
|
await Task.Run(() =>
|
||||||
Directory.CreateDirectory(_goldbergPath);
|
|
||||||
using (var archive = await Task.Run(() => ZipFile.OpenRead(archivePath)).ConfigureAwait(false))
|
|
||||||
{
|
|
||||||
foreach (var entry in archive.Entries)
|
|
||||||
{
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var fullPath = Path.Combine(_goldbergPath, entry.FullName);
|
|
||||||
if (string.IsNullOrEmpty(entry.Name))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(fullPath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entry.ExtractToFile(fullPath, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
errorOccured = true;
|
|
||||||
_log.Error($"Error while trying to extract {entry.FullName}");
|
|
||||||
_log.Error(e.ToString);
|
|
||||||
}
|
|
||||||
}).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errorOccured)
|
|
||||||
{
|
|
||||||
ShowErrorMessage();
|
|
||||||
_log.Warn("Error occured while extraction! Please setup Goldberg manually");
|
|
||||||
}
|
|
||||||
_log.Info("Extraction was successful!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ShowErrorMessage()
|
|
||||||
{
|
|
||||||
if (Directory.Exists(_goldbergPath))
|
|
||||||
{
|
{
|
||||||
Directory.Delete(_goldbergPath, true);
|
Directory.Delete(_goldbergPath, true);
|
||||||
}
|
ZipFile.ExtractToDirectory(archivePath, _goldbergPath);
|
||||||
|
}).ConfigureAwait(false);
|
||||||
Directory.CreateDirectory(_goldbergPath);
|
_log.Debug("Extraction done!");
|
||||||
MessageBox.Show("Could not setup Goldberg Emulator!\n" +
|
|
||||||
"Please download it manually and extract its content into the \"goldberg\" subfolder!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://gitlab.com/Mr_Goldberg/goldberg_emulator/-/blob/master/generate_interfaces_file.cpp
|
// https://gitlab.com/Mr_Goldberg/goldberg_emulator/-/blob/master/generate_interfaces_file.cpp
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -20,9 +21,9 @@ namespace GoldbergGUI.Core.Services
|
|||||||
public interface ISteamService
|
public interface ISteamService
|
||||||
{
|
{
|
||||||
public Task Initialize(IMvxLog log);
|
public Task Initialize(IMvxLog log);
|
||||||
public Task<IEnumerable<SteamApp>> GetListOfAppsByName(string name);
|
public IEnumerable<SteamApp> GetListOfAppsByName(string name);
|
||||||
public Task<SteamApp> GetAppByName(string name);
|
public SteamApp GetAppByName(string name);
|
||||||
public Task<SteamApp> GetAppById(int appid);
|
public SteamApp GetAppById(int appid);
|
||||||
public Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb);
|
public Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,13 +79,14 @@ namespace GoldbergGUI.Core.Services
|
|||||||
private const string UserAgent =
|
private const string UserAgent =
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " +
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " +
|
||||||
"Chrome/87.0.4280.88 Safari/537.36";
|
"Chrome/87.0.4280.88 Safari/537.36";
|
||||||
|
|
||||||
private const string AppTypeGame = "game";
|
private const string AppTypeGame = "game";
|
||||||
private const string AppTypeDlc = "dlc";
|
private const string AppTypeDlc = "dlc";
|
||||||
private const string Database = "steamapps.cache";
|
private const string Database = "steamapps.cache";
|
||||||
|
|
||||||
private IMvxLog _log;
|
private IMvxLog _log;
|
||||||
|
|
||||||
private SQLiteAsyncConnection _db;
|
private SQLiteConnection _db;
|
||||||
|
|
||||||
public async Task Initialize(IMvxLog log)
|
public async Task Initialize(IMvxLog log)
|
||||||
{
|
{
|
||||||
@ -96,14 +98,10 @@ namespace GoldbergGUI.Core.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
_log = log;
|
_log = log;
|
||||||
_db = new SQLiteAsyncConnection(Database);
|
_db = new SQLiteConnection(Database);
|
||||||
//_db.CreateTable<SteamApp>();
|
_db.CreateTable<SteamApp>();
|
||||||
await _db.CreateTableAsync<SteamApp>()
|
|
||||||
//.ContinueWith(x => _log.Debug("Table success!"))
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
var countAsync = await _db.Table<SteamApp>().CountAsync().ConfigureAwait(false);
|
if (DateTime.Now.Subtract(File.GetLastWriteTimeUtc(Database)).TotalDays >= 1 || !_db.Table<SteamApp>().Any())
|
||||||
if (DateTime.Now.Subtract(File.GetLastWriteTimeUtc(Database)).TotalDays >= 1 || countAsync == 0)
|
|
||||||
{
|
{
|
||||||
foreach (var (appType, steamCache) in _caches)
|
foreach (var (appType, steamCache) in _caches)
|
||||||
{
|
{
|
||||||
@ -133,78 +131,74 @@ namespace GoldbergGUI.Core.Services
|
|||||||
cache.Add(steamApp);
|
cache.Add(steamApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _db.InsertAllAsync(cache, "OR IGNORE").ConfigureAwait(false);
|
_db.InsertAll(cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<SteamApp>> GetListOfAppsByName(string name)
|
public IEnumerable<SteamApp> GetListOfAppsByName(string name)
|
||||||
{
|
{
|
||||||
var query = await _db.Table<SteamApp>()
|
var listOfAppsByName = _db.Table<SteamApp>()
|
||||||
.Where(x => x.type == AppTypeGame).ToListAsync().ConfigureAwait(false);
|
.Where(x => x.type == AppTypeGame).Search(x => x.Name)
|
||||||
var listOfAppsByName = query.Search(x => x.Name)
|
|
||||||
.SetCulture(StringComparison.OrdinalIgnoreCase)
|
.SetCulture(StringComparison.OrdinalIgnoreCase)
|
||||||
.ContainingAll(name.Split(' '));
|
.ContainingAll(name.Split(' '));
|
||||||
return listOfAppsByName;
|
return listOfAppsByName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SteamApp> GetAppByName(string name)
|
public SteamApp GetAppByName(string name)
|
||||||
{
|
{
|
||||||
_log.Info($"Trying to get app {name}");
|
_log.Info($"Trying to get app {name}");
|
||||||
var comparableName = PrepareStringToCompare(name);
|
var comparableName = PrepareStringToCompare(name);
|
||||||
var app = await _db.Table<SteamApp>()
|
var app = _db.Table<SteamApp>()
|
||||||
.FirstOrDefaultAsync(x => x.type == AppTypeGame && x.ComparableName.Equals(comparableName))
|
.FirstOrDefault(x => x.type == AppTypeGame && x.ComparableName.Equals(comparableName));
|
||||||
.ConfigureAwait(false);
|
|
||||||
if (app != null) _log.Info($"Successfully got app {app}");
|
if (app != null) _log.Info($"Successfully got app {app}");
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SteamApp> GetAppById(int appid)
|
public SteamApp GetAppById(int appid)
|
||||||
{
|
{
|
||||||
_log.Info($"Trying to get app with ID {appid}");
|
_log.Info($"Trying to get app with ID {appid}");
|
||||||
var app = await _db.Table<SteamApp>().Where(x => x.type == AppTypeGame)
|
var app = _db.Table<SteamApp>().Where(x => x.type == AppTypeGame)
|
||||||
.FirstOrDefaultAsync(x => x.AppId.Equals(appid)).ConfigureAwait(false);
|
.FirstOrDefault(x => x.AppId.Equals(appid));
|
||||||
if (app != null) _log.Info($"Successfully got app {app}");
|
if (app != null) _log.Info($"Successfully got app {app}");
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb)
|
public async Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb)
|
||||||
{
|
{
|
||||||
|
_log.Info("Get DLC");
|
||||||
var dlcList = new List<SteamApp>();
|
var dlcList = new List<SteamApp>();
|
||||||
if (steamApp != null)
|
if (steamApp != null)
|
||||||
{
|
{
|
||||||
_log.Info($"Get DLC for App {steamApp}");
|
|
||||||
var task = AppDetails.GetAsync(steamApp.AppId);
|
var task = AppDetails.GetAsync(steamApp.AppId);
|
||||||
var steamAppDetails = await task.ConfigureAwait(true);
|
var steamAppDetails = await task.ConfigureAwait(true);
|
||||||
if (steamAppDetails.Type == AppTypeGame)
|
if (steamAppDetails.Type == AppTypeGame)
|
||||||
{
|
{
|
||||||
steamAppDetails.DLC.ForEach(async x =>
|
steamAppDetails.DLC.ForEach(x =>
|
||||||
{
|
{
|
||||||
var result = await _db.Table<SteamApp>().Where(z => z.type == AppTypeDlc)
|
var result = _db.Table<SteamApp>().Where(z => z.type == AppTypeDlc)
|
||||||
.FirstOrDefaultAsync(y => y.AppId.Equals(x)).ConfigureAwait(true)
|
.FirstOrDefault(y => y.AppId.Equals(x))
|
||||||
?? new SteamApp {AppId = x, Name = $"Unknown DLC {x}"};
|
?? new SteamApp {AppId = x, Name = $"Unknown DLC {x}"};
|
||||||
dlcList.Add(result);
|
dlcList.Add(result);
|
||||||
_log.Debug($"{result.AppId}={result.Name}");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dlcList.ForEach(x => _log.Debug($"{x.AppId}={x.Name}"));
|
||||||
_log.Info("Got DLC successfully...");
|
_log.Info("Got DLC successfully...");
|
||||||
|
|
||||||
// Get DLC from SteamDB
|
// Get DLC from SteamDB
|
||||||
// Get Cloudflare cookie (not implemented)
|
// Get Cloudflare cookie
|
||||||
// Scrape and parse HTML page
|
// Scrape and parse HTML page
|
||||||
// Add missing to DLC list
|
// Add missing to DLC list
|
||||||
|
|
||||||
// Return current list if we don't intend to use SteamDB
|
// ReSharper disable once InvertIf
|
||||||
if (!useSteamDb) return dlcList;
|
if (useSteamDb)
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/");
|
var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/");
|
||||||
|
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
|
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
|
||||||
|
|
||||||
_log.Info($"Get SteamDB App {steamApp}");
|
_log.Info("Get SteamDB App");
|
||||||
var httpCall = client.GetAsync(steamDbUri);
|
var httpCall = client.GetAsync(steamDbUri);
|
||||||
var response = await httpCall.ConfigureAwait(false);
|
var response = await httpCall.ConfigureAwait(false);
|
||||||
_log.Debug(httpCall.Status.ToString());
|
_log.Debug(httpCall.Status.ToString());
|
||||||
@ -220,7 +214,6 @@ namespace GoldbergGUI.Core.Services
|
|||||||
var query1 = doc.QuerySelector("#dlc");
|
var query1 = doc.QuerySelector("#dlc");
|
||||||
if (query1 != null)
|
if (query1 != null)
|
||||||
{
|
{
|
||||||
_log.Info("Got list of DLC from SteamDB.");
|
|
||||||
var query2 = query1.QuerySelectorAll(".app");
|
var query2 = query1.QuerySelectorAll(".app");
|
||||||
foreach (var element in query2)
|
foreach (var element in query2)
|
||||||
{
|
{
|
||||||
@ -249,11 +242,6 @@ namespace GoldbergGUI.Core.Services
|
|||||||
_log.Error("Could not get DLC from SteamDB!");
|
_log.Error("Could not get DLC from SteamDB!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_log.Error("Could not get DLC from SteamDB! Skipping...");
|
|
||||||
_log.Error(e.ToString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -321,7 +321,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
|
|
||||||
MainWindowEnabled = false;
|
MainWindowEnabled = false;
|
||||||
StatusText = "Trying to find AppID...";
|
StatusText = "Trying to find AppID...";
|
||||||
var appByName = await _steam.GetAppByName(_gameName).ConfigureAwait(false);
|
var appByName = _steam.GetAppByName(_gameName);
|
||||||
if (appByName != null)
|
if (appByName != null)
|
||||||
{
|
{
|
||||||
GameName = appByName.Name;
|
GameName = appByName.Name;
|
||||||
@ -329,7 +329,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var list = await _steam.GetListOfAppsByName(GameName).ConfigureAwait(false);
|
var list = _steam.GetListOfAppsByName(GameName);
|
||||||
var steamApps = list as SteamApp[] ?? list.ToArray();
|
var steamApps = list as SteamApp[] ?? list.ToArray();
|
||||||
if (steamApps.Length == 1)
|
if (steamApps.Length == 1)
|
||||||
{
|
{
|
||||||
@ -364,7 +364,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var steamApp = await _steam.GetAppById(AppId).ConfigureAwait(false);
|
var steamApp = await Task.Run(() => _steam.GetAppById(AppId)).ConfigureAwait(false);
|
||||||
if (steamApp != null) GameName = steamApp.Name;
|
if (steamApp != null) GameName = steamApp.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user