-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ready for public (added docs and readme)
- Loading branch information
Showing
9 changed files
with
397 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# FortniteDownloader | ||
|
||
## A library to download and process Fortnite's game files | ||
|
||
### Features | ||
- Parse a download manifest from the Epic Games Launcher or manually by url | ||
- Support for both: json-serialized and binary-serialized manifests | ||
- Download all files from a parsed manifest individually | ||
- Implements the FileProvider interface from JFortniteParse with reading from Manifests. | ||
The main benefit is that only the chunks you need are downloaded | ||
- Preload chunks for a file, that you might need later. | ||
|
||
### Usage | ||
|
||
#### 1. Load a manifest | ||
There are multiple ways of loading a manifest | ||
- Loading a manifest from Epic Games Launcher's data | ||
```kotlin | ||
// It's recommended to reuse this as it does a login to the Epic Games Api | ||
// and you don't need to spam their api | ||
val launcherManifestDownloader = LauncherManifestDownloader() | ||
// The current version information. Can be used to get the build version for example | ||
// Use this to look for updates as it doesn't download the manifest immediately | ||
val info = launcherManifestDownloader.getManifestInfo(Platform.Windows, Game.Fortnite) | ||
val manifest = ManifestLoader.downloadManifest(info) | ||
// OR if you want to download the manifest immediately | ||
val (info, manifest) = launcherManifestDownloader.downloadManifest(Platform.Windows, Game.Fortnite) | ||
``` | ||
- Loading a manifest from a url | ||
```kotlin | ||
val url = "..." | ||
val manifest = ManifestLoader.downloadManifest(url) | ||
``` | ||
- Loading a manifest from a file on your disk | ||
```kotlin | ||
val file = File("...") | ||
// This is needed to determine the url of the chunks. | ||
// It's the same path as where you download manifests from | ||
val cloudDir = ".../CloudDir" | ||
val manifest = ManifestLoader.loadManifest(file, cloudDir) | ||
``` | ||
- Loading a manifest from memory | ||
```kotlin | ||
val bytes = ByteArray() | ||
val cloudDir = ".../CloudDir" | ||
val manifest = Manifest.parse(bytes, cloudDir) | ||
``` | ||
#### 2. Mount the manifest | ||
Once you got a manifest you can mount it to start reading from it | ||
- Create a MountedBuild | ||
```kotlin | ||
val tempFolder = File(".downloaderChunks") | ||
// ChunkPoolCapacity = Amount of chunks kept in memory, don't put this too high | ||
// NumThreads = Amount of threads used to read concurrently, too many might cause errors | ||
val mountedBuild = MountedBuild(manifest, tempFolder, chunkPoolCapacity = 20, numThreads = 20) | ||
``` | ||
- Download an entire file | ||
```kotlin | ||
val fileName = "FortniteGame/Content/Paks/pakchunk0-WindowsClient.pak" | ||
val outputFile = File("pakchunk0-WindowsClient.pak") | ||
val success = mountedBuild.downloadEntireFile(fileName, outputFile) { readBytes, size -> | ||
println("Downloading $fileName: $readBytes of $size") | ||
} | ||
if (success) | ||
println("Downloaded $fileName successfully") | ||
``` | ||
- Reading into a buffer from a file | ||
```kotlin | ||
val fileName = "FortniteGame/Content/Paks/pakchunk0-WindowsClient.pak" | ||
val output = ByteArray(2000) | ||
val success = mountedBuild.fileRead(fileName, output, destOffset = 0, offset = 0, length = 2000) | ||
if (success) | ||
println("Downloaded 2000 bytes from $fileName successfully") | ||
``` | ||
- Preloading chunks of a file | ||
```kotlin | ||
val fileName = "FortniteGame/Content/Paks/pakchunk0-WindowsClient.pak" | ||
val success = mountedBuild.preloadChunks(fileName) { pos, size -> | ||
println("Preloaded $pos of $size chunks") | ||
} | ||
if (success) | ||
println("Preloaded chunks from $fileName successfully") | ||
``` | ||
#### 3. Create a FileProvider | ||
With a MountedBuild you can also create a FileProvider that can be used to easily read | ||
from the game files while just downloading the chunks needed | ||
```kotlin | ||
val provider = ManifestFileProvider( | ||
mountedBuild, | ||
paksToSkip = emptyList(), | ||
localFilesFolder = File("localFiles"), // can also just be null | ||
game = Ue4Version.GAME_UE4_LATEST, | ||
concurrent = true // set to true if thread-safety is needed | ||
) | ||
provider.submitKey(FGuid.mainGuid, "0x...") | ||
``` | ||
After that you can just use it exactly like the DefaultFileProvider described in [JFortniteParse's](https://github.com/FabianFG/JFortniteParse) docs | ||
|
||
### Dependency | ||
|
||
##### Maven | ||
- Add the repository | ||
```xml | ||
<repositories> | ||
<repository> | ||
<id>bintray-fungamesleaks-mavenRepo</id> | ||
<name>bintray</name> | ||
<url>https://dl.bintray.com/fungamesleaks/mavenRepo</url> | ||
</repository> | ||
</repositories> | ||
``` | ||
- Add the dependency | ||
```xml | ||
<dependency> | ||
<groupId>me.fabianfg</groupId> | ||
<artifactId>FortniteDownloader</artifactId> | ||
<version>1.5</version> | ||
</dependency> | ||
``` | ||
##### Gradle | ||
- Add the repository | ||
```groovy | ||
repositories { | ||
maven { | ||
url "https://dl.bintray.com/fungamesleaks/mavenRepo" | ||
} | ||
} | ||
``` | ||
- Add the dependency | ||
```groovy | ||
implementation 'me.fabianfg:FortniteDownloader:1.5' | ||
``` | ||
|
||
### Credits | ||
|
||
Inspired and partially based on [EGL2](https://github.com/WorkingRobot/EGL2) (mainly the chunk storage and mounted build functionality / design) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.