Skip to content

Commit

Permalink
Version 0.3.0
Browse files Browse the repository at this point in the history
~~The Obligatory August 31 update~~
Make all scripts invokable from the command line
Remove deprecated scripts
Update README
  • Loading branch information
mos9527 committed Aug 31, 2024
1 parent e7fe8f7 commit 98629df
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 142 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# sssekai
Command-line tool (w/Python API support) for downloading/deobfuscating the game's assets, along with some other tools.
Command-line tool (w/Python API support) for Project SEKAI (JP: プロジェクトセカイ カラフルステージ! feat.初音ミク) game assets.

# Installation
**For Windows Users** : Builds are available [here](https://github.com/mos9527/sssekai/releases)
Expand Down
4 changes: 2 additions & 2 deletions sssekai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__VERSION_MAJOR__ = 0
__VERSION_MINOR__ = 2
__VERSION_PATCH__ = 9
__VERSION_MINOR__ = 3
__VERSION_PATCH__ = 0

__version__ = '%s.%s.%s' % (__VERSION_MAJOR__,__VERSION_MINOR__,__VERSION_PATCH__)
17 changes: 17 additions & 0 deletions sssekai/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from sssekai.entrypoint.abcache import main_abcache, DEFAULT_CACHE_DB_FILE
from sssekai.entrypoint.live2dextract import main_live2dextract
from sssekai.entrypoint.spineextract import main_spineextract
from sssekai.entrypoint.apphash import main_apphash
from sssekai.entrypoint.mvdata import main_mvdata
from sssekai.entrypoint.moc3paths import main_moc3paths
from sssekai.unity import sssekai_get_unity_version,sssekai_set_unity_version
def __main__():
from tqdm.std import tqdm as tqdm_c
Expand Down Expand Up @@ -82,6 +85,20 @@ def write(__s):
rla2json_parser.add_argument('infile', type=str, help='input file')
rla2json_parser.add_argument('outdir', type=str, help='output directory. multiple json files may be produced')
rla2json_parser.set_defaults(func=main_rla2json)
# apphash
apphash_parser = subparsers.add_parser('apphash', help='''Download/extract game AppHash values''')
apphash_parser.add_argument('--apk-src', type=str, help='APK source file (default: fetch from APKPure)', default=None)
apphash_parser.add_argument('--fetch', action='store_true', help='force fetching the latest APK')
apphash_parser.set_defaults(func=main_apphash)
# mvdata
mvdata_parser = subparsers.add_parser('mvdata', help='''Extract MV Data from AssetBundle''')
mvdata_parser.add_argument('cache_dir', type=str, help='cache directory')
mvdata_parser.add_argument('query', type=str, help='MV ID')
mvdata_parser.set_defaults(func=main_mvdata)
# moc3paths
moc3paths_parser = subparsers.add_parser('moc3paths', help='''Extract animation path CRCs from raw .moc3 binaries''')
moc3paths_parser.add_argument('indir', type=str, help='input directory')
moc3paths_parser.set_defaults(func=main_moc3paths)
# parse args
args = parser.parse_args()
# set logging level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,15 @@ def enum_package(zip_file):
if f.filename.lower().endswith('.apk'):
yield zipfile.ZipFile(zip_file.open(f))

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Dump appHash from Android APK')
parser.add_argument('--apk-src','-s', help='APK/APKX file to dump from')
parser.add_argument('--fetch', '-f', help='Use the latest game package from APKPure instead. Recommended for most cases.', action='store_true')
args = parser.parse_args()
def main_apphash(args):
env = UnityPy.Environment()
if args.fetch:
if not args.apk_src or args.fetch:
from requests import get
src = BytesIO()
print('Fetching latest game package from APKPure.')
print('Fetching latest game package from APKPure')
resp = get('https://d.apkpure.net/b/XAPK/com.sega.pjsekai?version=latest', stream=True)
size = resp.headers.get('Content-Length',-1)
for chunck in resp.iter_content(chunk_size=2**20):
for chunck in resp.iter_content(chunk_size=2**10):
src.write(chunck)
print('Downloading %d/%s' % (src.tell(), size), end='\r')
print()
Expand Down
32 changes: 32 additions & 0 deletions sssekai/entrypoint/moc3paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from io import BytesIO
from sssekai.unity.AssetBundle import load_assetbundle
from sssekai.fmt.moc3 import read_moc3
import sys, os
from UnityPy.enums import ClassIDType

def main_moc3paths(args):
ParameterNames = set()
PartNames = set()
tree = os.walk(args.indir)
for root, dirs, files in tree:
for fname in files:
file = os.path.join(root,fname)
with open(file,'rb') as f:
env = load_assetbundle(f)
for obj in env.objects:
if obj.type == ClassIDType.TextAsset:
data = obj.read()
out_name : str = data.name
if out_name.endswith('.moc3'):
parts, parameters = read_moc3(BytesIO(data.script.tobytes()))
ParameterNames.update(parameters)
PartNames.update(parts)
from zlib import crc32
print('NAMES_CRC_TBL = {')
for name in sorted(list(PartNames)):
fullpath = 'Parts/' + name
print(' %d:"%s",' % (crc32(fullpath.encode('utf-8')), fullpath))
for name in sorted(list(ParameterNames)):
fullpath = 'Parameters/' + name
print(' %d:"%s",' % (crc32(fullpath.encode('utf-8')), fullpath))
print('}')
10 changes: 1 addition & 9 deletions sssekai/scripts/dump_mvdata.py → sssekai/entrypoint/mvdata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sssekai.unity.AssetBundle import load_assetbundle
from sssekai.abcache import AbCache, AbCacheConfig
import os, json

def main_mvdata(args):
from UnityPy.enums import ClassIDType
cache_dir = args.cache_dir
Expand All @@ -24,11 +24,3 @@ def main_mvdata(args):
break
mvdata = mvdata_items[mvdata_lut[args.query]]
print(json.dumps(mvdata, indent=4,ensure_ascii=False))

if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Dump MVData')
parser.add_argument('cache_dir', help='live_pv\mv_data directory. Downloaded by sssekai abcache.')
parser.add_argument('query', help='Query')
args = parser.parse_args()
main_mvdata(args)
31 changes: 0 additions & 31 deletions sssekai/scripts/dump_moc3_animation_path.py

This file was deleted.

14 changes: 0 additions & 14 deletions sssekai/scripts/dump_source_anim_paths.py

This file was deleted.

77 changes: 0 additions & 77 deletions sssekai/scripts/mitmproxy_sekai_api.py

This file was deleted.

0 comments on commit 98629df

Please sign in to comment.