Skip to content

Commit

Permalink
Version 0.4.5
Browse files Browse the repository at this point in the history
Add tests for `spineextract`
Add tests for `apphash`
Fix appHash reader (again)
Bump required UnityPy version to >=1.20.10
  • Loading branch information
mos9527 committed Oct 26, 2024
1 parent 6dc6030 commit 07cf8ee
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 20 deletions.
40 changes: 30 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: SpineExtract test",
"type": "debugpy",
"request": "launch",
"module": "tests.test_spine",
"justMyCode": false
},
{
"name": "Python: Live2DExtract test",
"type": "debugpy",
"request": "launch",
"module": "tests.test_live2d",
"justMyCode": false
},
{
"name": "Python: AppHash test",
"type": "debugpy",
"request": "launch",
"module": "tests.test_apphash",
"justMyCode": false
},
{
"name": "Python: Current File",
"type": "python",
Expand All @@ -21,7 +42,7 @@
"args": [
"--log-level",
"DEBUG",
"abcache",
"abcache",
"--app-version",
"4.0.0",
"--app-appHash",
Expand All @@ -37,7 +58,7 @@
"args": [
"--log-level",
"DEBUG",
"abcache",
"abcache",
"--app-version",
"3.8.1",
"--app-appHash",
Expand All @@ -46,7 +67,7 @@
"D:\\proseka_reverse\\masterdata"
],
"justMyCode": true
},
},
{
"name": "Python: AbCache (no update)",
"type": "python",
Expand All @@ -62,7 +83,7 @@
".*characterv2/face/21/.*"
],
"justMyCode": true
},
},
{
"name": "Python: MVData",
"type": "python",
Expand Down Expand Up @@ -120,7 +141,7 @@
"C:\\Users\\mos9527\\Desktop\\pjsk_hash\\pjsk_350.apk"
],
"justMyCode": false
},
},
{
"name": "Python: usmdemux",
"type": "python",
Expand Down Expand Up @@ -177,20 +198,19 @@
"program": "${workspaceFolder}/tests/tests_main.py",
"console": "integratedTerminal",
"justMyCode": false,
"args": [
]
"args": []
},
{
"name": "Python: RLA Test (Single File)",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/sssekai/fmt/rla.py",
"console": "integratedTerminal",
"justMyCode": false,
"args": [
"justMyCode": false,
"args": [
// "D:\\proseka_reverse\\sse_packet_importer\\packets\\streaming_vbs_1\\sekai_30_00000006.rla.bytes"
"D:\\proseka_reverse\\sse_packet_importer\\packets\\4268\\1728191806276-0.bin"
]
},
},
]
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
install_requires=[
"msgpack",
"pycryptodome",
"unitypy >= 1.20.4",
"unitypy >= 1.20.10",
"wannacri",
"python-json-logger",
"tqdm",
Expand Down
6 changes: 3 additions & 3 deletions sssekai/entrypoint/apphash.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def main_apphash(args):
env = load_assetbundle(BytesIO(f.read()))
print("*** AppHash ***")
for obj in env.objects:
obj = obj.read()
hashStr = HASHREGEX.finditer(obj.object_reader.get_raw_data())
# TODO: Dump actual typetree data from the game itself?
hashStr = HASHREGEX.finditer(obj.get_raw_data())
for m in hashStr:
print(m.group().decode(), obj.m_Name)
print(m.group().decode())
12 changes: 6 additions & 6 deletions sssekai/entrypoint/spineextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ def main_spineextract(args):
os.makedirs(outdir, exist_ok=True)
with open(args.infile, "rb") as f:
env = load_assetbundle(f)
objects = [pobj.read() for pobj in env.objects]
objects = [(pobj, pobj.read()) for pobj in env.objects]
binaries = {
obj.m_Name: obj
for obj in objects
if getattr(obj, "type", None) in {ClassIDType.TextAsset}
for pobj, obj in objects
if pobj.type in {ClassIDType.TextAsset}
}
textures = {
obj.m_Name: obj
for obj in objects
if getattr(obj, "type", None) in {ClassIDType.Texture2D}
for pobj, obj in objects
if pobj.type in {ClassIDType.Texture2D}
}
spines = set()
for name in binaries:
Expand All @@ -35,7 +35,7 @@ def main_spineextract(args):
logger.info("...has Atlas %s" % spine)
with open(os.path.join(outdir, spine, spine + ".atlas.txt"), "wb") as f:
f.write(atlas.m_Script.encode("utf-8", "surrogateescape"))
texfiles = [line.strip() for line in atlas.text.split("\n")]
texfiles = [line.strip() for line in atlas.m_Script.split("\n")]
texfiles = [
".".join(line.split(".")[:-1])
for line in texfiles
Expand Down
Binary file added tests/spine/base_model
Binary file not shown.
18 changes: 18 additions & 0 deletions tests/test_spine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from . import *


def test_spineextract():
from sssekai.entrypoint.spineextract import main_spineextract

result = main_spineextract(
NamedDict(
{
"infile": sample_file_path("spine", "base_model"),
"outdir": TEMP_DIR,
}
)
)


if __name__ == "__main__":
test_spineextract()

0 comments on commit 07cf8ee

Please sign in to comment.