release: v1.0.2
加固:release 构建 + R8 混淆,清理无用资源,修启动链路
This commit is contained in:
1 parent
5b85408f17
commit
967e93af98
29 files changed
+1640
-1490
No files matched your search
@@ -19,6 +19,7 @@ from __future__ import annotations
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
@@ -99,7 +100,19 @@ def parse_title(path: str) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def collect(pkg: str, sub: str, filename: str, parser) -> list:
|
||||
def pack_of(pkg: str) -> str:
|
||||
"""从包目录名取出包号:SDGB_A041_20261020134418_0 -> A041。
|
||||
|
||||
目录名里没有 A0xx 时回退取全部数字段里第一个 3 位纯数字,
|
||||
再不行返回空串(这条就归到「无归属」)。
|
||||
"""
|
||||
for part in re.split(r"[\\/_\-\s]+", os.path.basename(os.path.normpath(pkg))):
|
||||
if re.fullmatch(r"A\d{3}", part):
|
||||
return part
|
||||
return ""
|
||||
|
||||
|
||||
def collect(pkg: str, sub: str, filename: str, parser, pack: str = "") -> list:
|
||||
out = []
|
||||
base = os.path.join(pkg, sub)
|
||||
if not os.path.isdir(base):
|
||||
@@ -113,6 +126,8 @@ def collect(pkg: str, sub: str, filename: str, parser) -> list:
|
||||
print(" 跳过 %s:%s" % (p, exc))
|
||||
continue
|
||||
if item.get("id"):
|
||||
if pack:
|
||||
item["pack"] = pack
|
||||
out.append(item)
|
||||
return out
|
||||
|
||||
@@ -133,6 +148,13 @@ def merge(old: list, new: list):
|
||||
cur = old[i]
|
||||
dirty = False
|
||||
for k, v in item.items():
|
||||
if k == "pack":
|
||||
# 包归属记首次出现的那个包:已有值不覆盖,
|
||||
# 空值(早先水鱼补的曲)才由包补上
|
||||
if v and not cur.get("pack"):
|
||||
cur["pack"] = v
|
||||
dirty = True
|
||||
continue
|
||||
if k == "notes":
|
||||
# 谱面:包里启用的档位比旧的更权威
|
||||
if any(n["level"] or n["levelDecimal"] for n in v):
|
||||
@@ -214,8 +236,11 @@ def main():
|
||||
music_old = json.load(io.open(music_path, encoding="utf-8"))
|
||||
title_old = json.load(io.open(title_path, encoding="utf-8"))
|
||||
|
||||
pkg_music = collect(pkg, "music", "Music.xml", parse_music)
|
||||
pkg_title = collect(pkg, "title", "Title.xml", parse_title)
|
||||
pkg_pack = pack_of(pkg)
|
||||
pkg_music = collect(pkg, "music", "Music.xml", parse_music, pkg_pack)
|
||||
pkg_title = collect(pkg, "title", "Title.xml", parse_title, pkg_pack)
|
||||
print("包号:%s%s" % (pkg_pack or "(未识别)",
|
||||
"" if pkg_pack else ",曲目会归到「无归属」"))
|
||||
print("包里:曲目 %d 首 / 称号 %d 个" % (len(pkg_music), len(pkg_title)))
|
||||
|
||||
music_new, m_add, m_upd = merge(music_old, pkg_music)
|
||||
|
||||
Reference in new issue
Block a user