mirror of
https://github.com/4sval/FModel.git
synced 2026-04-16 22:46:09 -05:00
Move hotfixes too
This commit is contained in:
parent
88383c30f0
commit
56dd9633a3
|
|
@ -1,4 +1,7 @@
|
|||
using FModel.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using FModel.Framework;
|
||||
using FModel.ViewModels.ApiEndpoints;
|
||||
using RestSharp;
|
||||
|
||||
|
|
@ -18,7 +21,6 @@ public class ApiEndpointViewModel
|
|||
public FortniteApiEndpoint FortniteApi { get; }
|
||||
public ValorantApiEndpoint ValorantApi { get; }
|
||||
public FortniteCentralApiEndpoint CentralApi { get; }
|
||||
public BenbotApiEndpoint BenbotApi { get; }
|
||||
public EpicApiEndpoint EpicApi { get; }
|
||||
public FModelApi FModelApi { get; }
|
||||
|
||||
|
|
@ -27,8 +29,19 @@ public class ApiEndpointViewModel
|
|||
FortniteApi = new FortniteApiEndpoint(_client);
|
||||
ValorantApi = new ValorantApiEndpoint(_client);
|
||||
CentralApi = new FortniteCentralApiEndpoint(_client);
|
||||
BenbotApi = new BenbotApiEndpoint(_client);
|
||||
EpicApi = new EpicApiEndpoint(_client);
|
||||
FModelApi = new FModelApi(_client);
|
||||
}
|
||||
|
||||
public async Task DownloadFileAsync(string fileLink, string installationPath)
|
||||
{
|
||||
var request = new FRestRequest(fileLink);
|
||||
var data = _client.DownloadData(request) ?? Array.Empty<byte>();
|
||||
await File.WriteAllBytesAsync(installationPath, data);
|
||||
}
|
||||
|
||||
public void DownloadFile(string fileLink, string installationPath)
|
||||
{
|
||||
DownloadFileAsync(fileLink, installationPath).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FModel.Framework;
|
||||
using FModel.ViewModels.ApiEndpoints.Models;
|
||||
using RestSharp;
|
||||
using Serilog;
|
||||
|
||||
namespace FModel.ViewModels.ApiEndpoints;
|
||||
|
||||
public class BenbotApiEndpoint : AbstractApiProvider
|
||||
{
|
||||
public BenbotApiEndpoint(RestClient client) : base(client)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, Dictionary<string, string>>> GetHotfixesAsync(CancellationToken token, string language = "en-US")
|
||||
{
|
||||
var request = new FRestRequest("https://benbot.app/api/v1/hotfixes")
|
||||
{
|
||||
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
|
||||
};
|
||||
request.AddParameter("lang", language);
|
||||
var response = await _client.ExecuteAsync<Dictionary<string, Dictionary<string, string>>>(request, token).ConfigureAwait(false);
|
||||
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, response.ResponseUri?.OriginalString);
|
||||
return response.Data;
|
||||
}
|
||||
|
||||
public Dictionary<string, Dictionary<string, string>> GetHotfixes(CancellationToken token, string language = "en-US")
|
||||
{
|
||||
return GetHotfixesAsync(token, language).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public async Task DownloadFileAsync(string fileLink, string installationPath)
|
||||
{
|
||||
var request = new FRestRequest(fileLink);
|
||||
var data = _client.DownloadData(request);
|
||||
await File.WriteAllBytesAsync(installationPath, data);
|
||||
}
|
||||
|
||||
public void DownloadFile(string fileLink, string installationPath)
|
||||
{
|
||||
DownloadFileAsync(fileLink, installationPath).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FModel.Framework;
|
||||
using FModel.ViewModels.ApiEndpoints.Models;
|
||||
|
|
@ -44,4 +45,21 @@ public class FortniteCentralApiEndpoint : AbstractApiProvider
|
|||
{
|
||||
return GetMappingsAsync(token).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, Dictionary<string, string>>> GetHotfixesAsync(CancellationToken token, string language = "en")
|
||||
{
|
||||
var request = new FRestRequest("https://fortnitecentral.gmatrixgames.ga/api/v1/hotfixes")
|
||||
{
|
||||
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
|
||||
};
|
||||
request.AddParameter("lang", language);
|
||||
var response = await _client.ExecuteAsync<Dictionary<string, Dictionary<string, string>>>(request, token).ConfigureAwait(false);
|
||||
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, response.ResponseUri?.OriginalString);
|
||||
return response.Data;
|
||||
}
|
||||
|
||||
public Dictionary<string, Dictionary<string, string>> GetHotfixes(CancellationToken token, string language = "en")
|
||||
{
|
||||
return GetHotfixesAsync(token, language).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ public class ApplicationViewModel : ViewModel
|
|||
var vgmZipFilePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", "vgmstream-win.zip");
|
||||
if (File.Exists(vgmZipFilePath)) return;
|
||||
|
||||
await ApplicationService.ApiEndpointView.BenbotApi.DownloadFileAsync("https://github.com/vgmstream/vgmstream/releases/latest/download/vgmstream-win.zip", vgmZipFilePath);
|
||||
await ApplicationService.ApiEndpointView.DownloadFileAsync("https://github.com/vgmstream/vgmstream/releases/latest/download/vgmstream-win.zip", vgmZipFilePath);
|
||||
if (new FileInfo(vgmZipFilePath).Length > 0)
|
||||
{
|
||||
var zip = ZipFile.Read(vgmZipFilePath);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
|
@ -93,7 +93,7 @@ public class BackupManagerViewModel : ViewModel
|
|||
await _threadWorkerView.Begin(_ =>
|
||||
{
|
||||
var fullPath = Path.Combine(Path.Combine(UserSettings.Default.OutputDirectory, "Backups"), SelectedBackup.FileName);
|
||||
_apiEndpointView.BenbotApi.DownloadFile(SelectedBackup.DownloadUrl, fullPath);
|
||||
_apiEndpointView.DownloadFile(SelectedBackup.DownloadUrl, fullPath);
|
||||
SaveCheck(fullPath, SelectedBackup.FileName, "downloaded", "download");
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
var mappingPath = Path.Combine(mappingsFolder, mapping.FileName);
|
||||
if (!File.Exists(mappingPath))
|
||||
{
|
||||
_apiEndpointView.BenbotApi.DownloadFile(mapping.Url, mappingPath);
|
||||
_apiEndpointView.DownloadFile(mapping.Url, mappingPath);
|
||||
}
|
||||
|
||||
Provider.MappingsContainer = new FileUsmapTypeMappingsProvider(mappingPath);
|
||||
|
|
@ -401,7 +401,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
if (Game != FGame.FortniteGame || HotfixedResourcesDone) return;
|
||||
await _threadWorkerView.Begin(cancellationToken =>
|
||||
{
|
||||
var hotfixes = ApplicationService.ApiEndpointView.BenbotApi.GetHotfixes(cancellationToken, Provider.GetLanguageCode(UserSettings.Default.AssetLanguage));
|
||||
var hotfixes = ApplicationService.ApiEndpointView.CentralApi.GetHotfixes(cancellationToken, Provider.GetLanguageCode(UserSettings.Default.AssetLanguage));
|
||||
if (hotfixes == null) return;
|
||||
|
||||
HotfixedResourcesDone = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user