Skip to content

Commit

Permalink
v2 rework
Browse files Browse the repository at this point in the history
  • Loading branch information
NotOfficer committed Apr 2, 2024
1 parent 0bac22e commit 8463009
Show file tree
Hide file tree
Showing 44 changed files with 2,252 additions and 1,073 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/nuget_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: NuGet Push

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore ./src

- name: Build
run: dotnet build ./src --no-restore --configuration Release

- name: Pack NuGet Package(s)
run: dotnet pack ./src --no-restore --no-build --configuration Release --output ./nuget-packages

- name: Upload Build Artifact(s)
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./nuget-packages

- name: Push NuGet Package(s)
run: dotnet nuget push ./nuget-packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
44 changes: 41 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# User-specific files
*.rsuser
Expand Down Expand Up @@ -90,6 +90,7 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
Expand Down Expand Up @@ -142,7 +143,9 @@ _TeamCity*
!.axoCover/settings.json

# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
coverage*.json
coverage*.xml
coverage*.info

# Visual Studio code coverage results
*.coverage
Expand Down Expand Up @@ -291,6 +294,17 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp

# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp

# Visual Studio 6 technical files
*.ncb
*.aps

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
Expand Down Expand Up @@ -347,6 +361,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/

# Visual Studio History (VSHistory) files
.vshistory/

# BeatPulse healthcheck temp database
healthchecksdb

Expand All @@ -357,4 +374,25 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp

# JetBrains Rider
*.sln.iml
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 NotOfficer
Copyright (c) 2024 NotOfficer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">

# EpicManifestParser
A parser for EpicGames manifests.
A .NET parser & downloader for EpicGames manifests.

[![GitHub release](https://img.shields.io/github/v/release/NotOfficer/EpicManifestParser?logo=github)](https://github.com/NotOfficer/EpicManifestParser/releases/latest) [![Nuget](https://img.shields.io/nuget/v/EpicManifestParser?logo=nuget)](https://www.nuget.org/packages/EpicManifestParser) ![Nuget DLs](https://img.shields.io/nuget/dt/EpicManifestParser?logo=nuget) [![GitHub issues](https://img.shields.io/github/issues/NotOfficer/EpicManifestParser?logo=github)](https://github.com/NotOfficer/EpicManifestParser/issues) [![GitHub License](https://img.shields.io/github/license/NotOfficer/EpicManifestParser)](https://github.com/NotOfficer/EpicManifestParser/blob/master/LICENSE)

Expand All @@ -13,5 +13,5 @@ A parser for EpicGames manifests.

## Usage

Please take a look into [this](https://github.com/NotOfficer/EpicManifestParser/blob/master/src/EpicManifestParser.Test/Program.cs).
A more detailed documentation isn't available right now.
Please take a look into [this](https://github.com/NotOfficer/EpicManifestParser/blob/master/src/EpicManifestParser.Playground/Program.cs).
A more detailed documentation isn't available right now.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EpicManifestParser\EpicManifestParser.csproj" />
</ItemGroup>

</Project>
120 changes: 120 additions & 0 deletions src/EpicManifestParser.Playground/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

using System.Diagnostics;

using BenchmarkDotNet.Attributes;

using EpicManifestParser;
using EpicManifestParser.Api;
using EpicManifestParser.UE;

using ZlibngDotNet;

//BenchmarkDotNet.Running.BenchmarkRunner.Run<Benchmarks>();
//return;

var client = new HttpClient(new HttpClientHandler
{
UseProxy = false,
UseCookies = false
});

using var manifestResponse = await client.GetAsync("https://media.wtf/XlQk.json");
var manifestInfo1 = await manifestResponse.Content.ReadManifestInfoAsync();
var manifestInfo2 = await ManifestInfo.DeserializeFileAsync(Benchmarks.ManifestInfoPath);

var randomGuid = FGuid.Random();
var chunkGuid = new FGuid("A76EAD354E9F6F06D0E75CAC2AB1B56C");

var zlibng = new Zlibng(Benchmarks.ZlibngPath);
var manifestBuffer = await File.ReadAllBytesAsync(Benchmarks.ManifestPath);

var sw = Stopwatch.StartNew();
var manifest = FBuildPatchAppManifest.Deserialize(manifestBuffer, options =>
{
options.Zlibng = zlibng;
options.Client = client;
options.ChunkBaseUrl = "http://epicgames-download1.akamaized.net/Builds/Fortnite/CloudDir/";
options.ChunkCacheDirectory = Path.Combine(Benchmarks.DownloadsDir, "chunks_v2");
});
sw.Stop();
Console.WriteLine(Math.Round(sw.Elapsed.TotalMilliseconds, 0));

var testChunk = manifest.ChunkDataList[69];
var testBuffer = new byte[testChunk.WindowSize];
await testChunk.ReadDataAsync(testBuffer, manifest);
sw.Restart();
await testChunk.ReadDataAsync(testBuffer, manifest);
sw.Stop();
Console.WriteLine(Math.Round(sw.Elapsed.TotalMilliseconds, 0));

{
var fileManifest = manifest.FileManifestList.First(x =>
x.Filename.EndsWith("/pakchunk0optional-WindowsClient.ucas", StringComparison.Ordinal));
var fileManifestStream = fileManifest.GetStream();
await fileManifestStream.SaveFileAsync(Path.Combine(Benchmarks.DownloadsDir, "pakchunk0optional-WindowsClient.ucas"));
var fileBuffer = await fileManifestStream.SaveBytesAsync();
FSHAHash.TryCompute(fileBuffer, out var hash);
}

var chunkUrl = $"http://epicgames-download1.akamaized.net/Builds/Fortnite/CloudDir/ChunksV4/{testChunk.GroupNumber:D2}/{testChunk.Hash:X16}_{testChunk.Guid}.chunk";
Console.WriteLine(chunkUrl);
await Task.Delay(-1);

[MemoryDiagnoser(false)]
public class Benchmarks
{
public static string DownloadsDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
public static string DocumentsDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Documents");

public static string ManifestPath = Path.Combine(DownloadsDir, "jDihDvwDD4VfI5Ss7Uy-BNIY91lqSw.manifest");
//public static string ManifestPath = Path.Combine(DownloadsDir, "apk_manifest.json");
//public static string ManifestPath = Path.Combine(DownloadsDir, "last_pc_manifest.json");
public static string ZlibngPath = Path.Combine(DocumentsDir, @"Libraries\zlib-ng2.dll");
public static string ManifestInfoPath = Path.Combine(DownloadsDir, "manifestinfo.json");

private byte[] _manifestBuffer = null!;
private Zlibng _zlibng = null!;
private byte[] _manifestInfoBuffer = null!;
private FFileManifestStream _fileManifestStream = null!;
private byte[] _fileBuffer = null!;

[GlobalSetup]
public void Setup()
{
_manifestBuffer = File.ReadAllBytes(ManifestPath);
_zlibng = new Zlibng(ZlibngPath);
_manifestInfoBuffer = File.ReadAllBytes(ManifestInfoPath);

var manifest = FBuildPatchAppManifest.Deserialize(_manifestBuffer, options =>
{
options.Zlibng = _zlibng;
options.ChunkBaseUrl = "http://epicgames-download1.akamaized.net/Builds/Fortnite/CloudDir/";
options.ChunkCacheDirectory = Path.Combine(DownloadsDir, "chunks_v2");
});
var fileManifest = manifest.FileManifestList.First(x =>
x.Filename.EndsWith("/pakchunk0optional-WindowsClient.ucas", StringComparison.Ordinal));
_fileManifestStream = fileManifest.GetStream();
_fileBuffer = new byte[fileManifest.FileSize];
}

[Benchmark]
public FBuildPatchAppManifest FBuildPatchAppManifest_Deserialize()
{
return FBuildPatchAppManifest.Deserialize(_manifestBuffer, options =>
{
options.Zlibng = _zlibng;
});
}

[Benchmark]
public ManifestInfo? ManifestInfo_Deserialize()
{
return ManifestInfo.Deserialize(_manifestInfoBuffer);
}

[Benchmark]
public async Task FFileManifestStream_Save()
{
await _fileManifestStream.SaveBytesAsync(_fileBuffer);
}
}
12 changes: 0 additions & 12 deletions src/EpicManifestParser.Test/EpicManifestParser.Test.csproj

This file was deleted.

52 changes: 0 additions & 52 deletions src/EpicManifestParser.Test/Program.cs

This file was deleted.

Loading

0 comments on commit 8463009

Please sign in to comment.