feat: more more more!

This commit is contained in:
tresabhi committed 2025-04-01 21:12:06 -05:00
1 parent 75f6f133ca
commit eb5e2a935c
2 files changed
+56 -30

No files matched your search

+28 -12
View File
@@ -41,17 +41,25 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_TOKEN }}
- uses: oven-sh/setup-bun@v1
- uses: actions/configure-pages@v5
- uses: actions/setup-dotnet@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
- name: Configure pages
uses: actions/configure-pages@v5
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0
- run: |
- name: Download Steam Depot
run: |
mkdir -p temp
echo "Downloading..."
@@ -67,11 +75,16 @@ jobs:
echo "Download complete; files:"
ls temp/depotDownloader
- run: bun install
- run: |
- name: Download dependencies
run: bun install
- name: Restore dependencies
run: |
cd src/BlitzKit.CLI
dotnet restore
- run: |
- name: Download client
run: |
chmod +x temp/depotDownloader/DepotDownloader
temp/depotDownloader/DepotDownloader \
-username "${{ env.DEPOT_DOWNLOADER_USERNAME }}" \
@@ -82,11 +95,13 @@ jobs:
-dir temp/depot \
-filelist filelist.txt
- run: |
- name: Download containers
run: |
cd src/BlitzKit.CLI
dotnet run unpack ../../temp/depot
- run: bun run build:website
- run: |
- name: Run API and build website
run: |
cd src/BlitzKit.CLI
dotnet run api --verbosepa &
SERVER_PID=$!
@@ -96,7 +111,8 @@ jobs:
kill $SERVER_PID || true
- uses: actions/upload-pages-artifact@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist/website
+28 -18
View File
@@ -1,20 +1,10 @@
using System.Text;
using System.Text.Json;
using BlitzKit.CLI.Models;
using BlitzKit.CLI.Quicktype.DLCManifest;
using BlitzKit.CLI.Utils;
using CUE4Parse.FileProvider;
using CUE4Parse.FileProvider.Objects;
using CUE4Parse.UE4.Pak;
using CUE4Parse.UE4.Pak.Objects;
using CUE4Parse.UE4.Readers;
using CUE4Parse.UE4.Versions;
using DotNet.Globbing;
using System.Net.Http;
using System.Threading;
using System.IO;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace BlitzKit.CLI.Functions
{
@@ -25,7 +15,7 @@ namespace BlitzKit.CLI.Functions
private const string TEMP_DEPOT_DIR = "../../temp/depot/";
public const string WG_DLC_DOMAIN = "http://dl-wotblitz-gc.wargaming.net";
private const string BUILD_MANIFEST_OS = "Windows";
private static readonly SemaphoreSlim semaphore = new(4); // Limit to 4 concurrent downloads
private static readonly SemaphoreSlim semaphore = new(8); // Limit to 4 concurrent downloads
public static async Task Unpack(string[] args)
{
@@ -68,13 +58,17 @@ namespace BlitzKit.CLI.Functions
{
var localContainerPath = Path.Combine(CONTAINERS_PATH, pakFile.FileName);
var fullContainerURL = $"{WG_DLC_DOMAIN}/dlc/{CONTENT_GROUP}/dlc/{pakFile.RelativeUrl}";
downloadTasks.Add(DownloadFileAsync(client, fullContainerURL, localContainerPath, manifest.PakFiles.Count));
downloadTasks.Add(
DownloadFileAsync(client, fullContainerURL, localContainerPath, manifest.PakFiles.Count)
);
}
await Task.WhenAll(downloadTasks);
PrettyLog.Log("Moving pre-bundled containers...");
foreach (var file in Directory.GetFiles(Path.Combine(TEMP_DEPOT_DIR, "Blitz/Content/Paks"), "*.pak"))
foreach (
var file in Directory.GetFiles(Path.Combine(TEMP_DEPOT_DIR, "Blitz/Content/Paks"), "*.pak")
)
{
File.Move(file, Path.Combine(CONTAINERS_PATH, Path.GetFileName(file)));
}
@@ -83,16 +77,31 @@ namespace BlitzKit.CLI.Functions
Directory.Delete(TEMP_DEPOT_DIR, true);
}
private static async Task DownloadFileAsync(HttpClient client, string url, string localPath, int totalFiles)
private static async Task DownloadFileAsync(
HttpClient client,
string url,
string localPath,
int totalFiles
)
{
await semaphore.WaitAsync();
try
{
using HttpResponseMessage response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead);
using HttpResponseMessage response = await client.GetAsync(
url,
HttpCompletionOption.ResponseHeadersRead
);
response.EnsureSuccessStatusCode();
using Stream contentStream = await response.Content.ReadAsStreamAsync(),
fileStream = new FileStream(localPath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true);
fileStream = new FileStream(
localPath,
FileMode.Create,
FileAccess.Write,
FileShare.None,
8192,
true
);
await contentStream.CopyToAsync(fileStream);
PrettyLog.Log($"Downloaded {Path.GetFileName(localPath)} ({totalFiles} total)");
@@ -111,11 +120,12 @@ namespace BlitzKit.CLI.Functions
{
PrettyLog.Log($"Fetching manifest for group {group} and build {build}");
string url = $"{WG_DLC_DOMAIN}/dlc/{group}/dlc/BuildManifest-{BUILD_MANIFEST_OS}-{build}.json";
string url =
$"{WG_DLC_DOMAIN}/dlc/{group}/dlc/BuildManifest-{BUILD_MANIFEST_OS}-{build}.json";
using HttpClient client = new();
string jsonString = await client.GetStringAsync(url);
return JsonSerializer.Deserialize<DlcManifest>(jsonString)
?? throw new Exception("Failed to deserialize manifest");
?? throw new Exception("Failed to deserialize manifest");
}
}
}