mirror of
https://github.com/Radiquum/anixart-patcher.git
synced 2025-09-03 17:55:33 +05:00
feat: introduce config path argument
This commit is contained in:
parent
8269d0d5b6
commit
bf59b2bbae
5 changed files with 23 additions and 21 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -7,4 +7,6 @@ decompiled
|
|||
dist
|
||||
__pycache__
|
||||
keystore.jks
|
||||
help
|
||||
help
|
||||
dev_patches
|
||||
dev.config.json
|
18
config.py
18
config.py
|
@ -1,3 +1,4 @@
|
|||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
@ -42,19 +43,26 @@ class Config(TypedDict):
|
|||
xml_ns: ConfigXmlNS
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(prog="anixart patcher")
|
||||
parser.add_argument("--config", help="path to config.json file", default="config.json")
|
||||
parser.add_argument("--no-decompile", action="store_true")
|
||||
parser.add_argument("--no-compile", action="store_true")
|
||||
parser.add_argument("--patch", action="store_true")
|
||||
parser.add_argument("--sign", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
def load_config() -> Config:
|
||||
config = None
|
||||
|
||||
if not os.path.exists("config.json"):
|
||||
if not os.path.exists(args.config):
|
||||
log.exception("file `config.json` is not found!")
|
||||
exit(1)
|
||||
|
||||
with open("./config.json", "r", encoding="utf-8") as file:
|
||||
with open(args.config, "r", encoding="utf-8") as file:
|
||||
config = json.loads(file.read())
|
||||
|
||||
log.setLevel(config.get("log_level", "NOTSET").upper())
|
||||
|
||||
return config
|
||||
|
||||
|
||||
config = load_config()
|
||||
config = load_config()
|
18
main.py
18
main.py
|
@ -2,28 +2,20 @@ from scripts.download_tools import check_and_download_all_tools
|
|||
from scripts.select_apk import get_apks, select_apk
|
||||
from scripts.select_patches import apply_patches, get_patches, select_patches
|
||||
from scripts.utils import check_java_version, compile_apk, decompile_apk, sign_apk
|
||||
from config import config, log, console
|
||||
from config import args, config, log, console
|
||||
|
||||
from time import time
|
||||
import math
|
||||
import argparse
|
||||
import yaml
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(prog="anixart patcher")
|
||||
parser.add_argument("--no-decompile", action="store_true")
|
||||
parser.add_argument("--no-compile", action="store_true")
|
||||
parser.add_argument("--patch", action="store_true")
|
||||
parser.add_argument("--sign", action="store_true")
|
||||
|
||||
|
||||
def patch():
|
||||
patches = get_patches()
|
||||
patches = select_patches(patches)
|
||||
statuses = apply_patches(patches)
|
||||
|
||||
statuses_ok = []
|
||||
statuses_err = []
|
||||
|
||||
for status in statuses:
|
||||
if status["status"]:
|
||||
console.print(f"{status['name']}: ✔", style="bold green")
|
||||
|
@ -35,8 +27,6 @@ def patch():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
|
||||
check_and_download_all_tools()
|
||||
check_java_version()
|
||||
|
||||
|
@ -78,7 +68,9 @@ if __name__ == "__main__":
|
|||
sign_apk(f"{apk.removesuffix(".apk")}-patched.apk")
|
||||
|
||||
log.info("Finished")
|
||||
log.info(f"install this apk file: `{config["folders"]["dist"]}/{apk.removesuffix(".apk")}-patched-aligned-signed.apk`")
|
||||
log.info(
|
||||
f"install this apk file: `{config["folders"]["dist"]}/{apk.removesuffix(".apk")}-patched-aligned-signed.apk`"
|
||||
)
|
||||
log.info(f"used and successful patches: {", ".join(statuses_ok)}")
|
||||
log.info(f"used and unsuccessful patches: {", ".join(statuses_err)}")
|
||||
log.info(f"time taken: {math.floor(end_time - start_time)}s")
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"new_package_name": "com.radiquum.anixart"
|
||||
"new_package_name": "com.swiftsoft.anixartd"
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"base_url": "https://anix-api.wah.su/",
|
||||
"base_url": "https://api-s.anixsekai.com/",
|
||||
"values": [
|
||||
{
|
||||
"file_path": "smali_classes2/com/swiftsoft/anixartd/network/api/ConfigApi.smali",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue