Skip to content

Commit

Permalink
Version 0.0.9
Browse files Browse the repository at this point in the history
spineextract: updated script
  • Loading branch information
mos9527 committed Apr 30, 2024
1 parent 014b095 commit 0448df5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
version=sssekai.__version__,
author="greats3an",
author_email="[email protected]",
description="",
description="Project SEKAI Asset Utility / PJSK 资源下载 + Live2D, Spine, USM 提取",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/mos9527/sssekai",
Expand Down
2 changes: 1 addition & 1 deletion sssekai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__VERSION_MAJOR__ = 0
__VERSION_MINOR__ = 0
__VERSION_PATCH__ = 8
__VERSION_PATCH__ = 9

__version__ = '%s.%s.%s' % (__VERSION_MAJOR__,__VERSION_MINOR__,__VERSION_PATCH__)

30 changes: 18 additions & 12 deletions sssekai/entrypoint/spineextract.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from sssekai.unity.AssetBundle import load_assetbundle
from UnityPy.enums import ClassIDType
from logging import getLogger
logger = getLogger(__name__)

Expand All @@ -8,31 +9,36 @@ def main_spineextract(args):
with open(args.infile, "rb") as f:
env = load_assetbundle(f)
objects = [pobj.read() for pobj in env.objects]
objects = {obj.name: obj for obj in objects if hasattr(obj,'name')}
binaries = {obj.name: obj for obj in objects if getattr(obj,'type',None) in {ClassIDType.TextAsset}}
textures = {obj.name: obj for obj in objects if getattr(obj,'type',None) in {ClassIDType.Texture2D}}
spines = set()
for name in objects:
for name in binaries:
if name.endswith(".atlas") or name.endswith(".skel"):
spines.add(".".join(name.split(".")[:-1]))
for spine in spines:
logger.info('Extracting %s' % spine)
atlas = objects.get(spine + ".atlas", None)
skel = objects.get(spine + ".skel", None)
texture = objects.get(spine, None)
atlas = binaries.get(spine + ".atlas", None)
skel = binaries.get(spine + ".skel", None)
os.makedirs(os.path.join(outdir, spine), exist_ok=True)
if atlas:
logger.info('...has Atlas %s' % spine)
with open(os.path.join(outdir, spine, spine + ".atlas.txt"), "wb") as f:
f.write(atlas.script)
texfiles = [line.strip() for line in atlas.text.split("\n")]
texfiles = ['.'.join(line.split('.')[:-1]) for line in texfiles if (line.endswith(".png"))]
for tex in texfiles:
logger.info('...has Texture %s' % tex)
textureobj = textures.get(tex, None)
if textureobj:
textureobj.image.save(os.path.join(outdir, spine, tex + '.png'))
else:
logger.warning('No texture found for %s' % tex)
else:
logger.warning("No atlas found for %s" % spine)
logger.warning("No atlas found for %s. Consequnetially, no textures cannot be exported either." % spine)

if skel:
logger.info('...has Skeleton %s' % spine)
with open(os.path.join(outdir, spine, spine + ".skel.bytes"), "wb") as f:
f.write(skel.script)
else:
logger.warning("No skel found for %s" % spine)

if texture:
with open(os.path.join(outdir, spine, spine + ".png"), "wb") as f:
texture.image.save(f)
else:
logger.warning("No texture found for %s" % spine)

0 comments on commit 0448df5

Please sign in to comment.