MinshuG / pyUE4Parse

ue4 asset parser/reader
MIT License
47 stars 16 forks source link

[bug] invalid start byte #6

Closed s1btea closed 2 years ago

s1btea commented 2 years ago

I tried to parse a graffiti image from path but I get this error. How i can solve this?

2022-06-09 19:41:24,662 - UE4Parse.DefaultFileProvider - INFO - Loading /ShooterGame/Content/Personalization/Sprays/Miscellaneous_Sprays/SaveOrBuy/Materials/Spray_SaveOrBuy_DisplayIcon.uasset Traceback (most recent call last): File "c:\Users\upsto\OneDrive\Github\FModel\Exporter\main.py", line 26, in package = provider.try_load_package(package_path) File "F:\lib\functools.py", line 926, in _method return method.get(obj, cls)(*args, *kwargs) File "F:\lib\site-packages\UE4Parse\Provider\DefaultFileProvider.py", line 132, in try_load_package return self.try_load_package(package, load_mode) File "F:\lib\functools.py", line 926, in _method return method.get(obj, cls)(args, **kwargs) File "F:\lib\site-packages\UE4Parse\Provider\DefaultFileProvider.py", line 164, in _ return LegacyPackageReader(uasset, uexp, ubulk, self, load_mode) File "F:\lib\site-packages\UE4Parse\Assets\PackageReader.py", line 95, in init self.PackageFileSummary = FPackageFileSummary(self.reader) File "F:\lib\site-packages\UE4Parse\Assets\Objects\FPackageFileSummary.py", line 96, in init self.SavedByEngineVersion = FEngineVersion(reader) File "F:\lib\site-packages\UE4Parse\Assets\Objects\FEngineVersion.py", line 16, in init self.Branch = reader.readFString() File "F:\lib\site-packages\UE4Parse\BinaryReader.py", line 192, in readFString return byte.decode("utf-8") UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8c in position 38: invalid start byte

Code:

from UE4Parse.Assets.Objects.FGuid import FGuid
from UE4Parse.Provider import DefaultFileProvider
from UE4Parse.Versions import EUEVersion, VersionContainer
from UE4Parse.Encryption import FAESKey

import logging

logging.getLogger("UE4Parse").setLevel(logging.INFO)

path = r"F:\Riot Games\VALORANT\live\ShooterGame\Content\Paks"

aeskeys = {
    FGuid(0,0,0,0): FAESKey("0x4BE71AF2459CF83899EC9DC2CB60E22AC4B3047E0211034BBABE9D174C069DD6"),
}

import gc; gc.disable()

provider = DefaultFileProvider(path, VersionContainer(EUEVersion.LATEST))
provider.initialize()
provider.submit_keys(aeskeys)

gc.enable()

package_path = 'ShooterGame/Content/Personalization/Sprays/Miscellaneous_Sprays/SaveOrBuy/Materials/Spray_SaveOrBuy_DisplayIcon.uasset'

package = provider.try_load_package(package_path)

if package is not None:
    package_dict = package.get_dict()

   import json
    with open('something.json', 'w') as f:
        json.dump(package_dict, f, indent=4)
MinshuG commented 2 years ago

change ue verison to GAME_VALORANT provider = DefaultFileProvider(path, VersionContainer(EUEVersion.GAME_VALORANT))

s1btea commented 2 years ago

Yes, that works. Thanks!