rewog 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rewog-3.0.0.dist-info/METADATA +518 -0
- rewog-3.0.0.dist-info/RECORD +70 -0
- rewog-3.0.0.dist-info/WHEEL +4 -0
- rewog-3.0.0.dist-info/entry_points.txt +3 -0
- rewog-3.0.0.dist-info/licenses/LICENSE +21 -0
- wog_dump/__init__.py +27 -0
- wog_dump/cli/__init__.py +1 -0
- wog_dump/cli/auth.py +128 -0
- wog_dump/cli/cache.py +123 -0
- wog_dump/cli/catalog.py +167 -0
- wog_dump/cli/convert.py +59 -0
- wog_dump/cli/decrypt.py +118 -0
- wog_dump/cli/download.py +214 -0
- wog_dump/cli/errors.py +76 -0
- wog_dump/cli/info.py +197 -0
- wog_dump/cli/main.py +250 -0
- wog_dump/cli/pipeline.py +152 -0
- wog_dump/cli/print_export.py +110 -0
- wog_dump/cli/render.py +210 -0
- wog_dump/cli/scene.py +248 -0
- wog_dump/cli/serve.py +57 -0
- wog_dump/cli/unpack.py +120 -0
- wog_dump/core/__init__.py +1 -0
- wog_dump/core/anim.py +99 -0
- wog_dump/core/api.py +154 -0
- wog_dump/core/auth.py +471 -0
- wog_dump/core/catalog.py +118 -0
- wog_dump/core/config.py +373 -0
- wog_dump/core/database.py +368 -0
- wog_dump/core/decrypt.py +317 -0
- wog_dump/core/download.py +688 -0
- wog_dump/core/export.py +643 -0
- wog_dump/core/glb.py +657 -0
- wog_dump/core/http.py +72 -0
- wog_dump/core/key_import.py +502 -0
- wog_dump/core/keys.py +295 -0
- wog_dump/core/paths.py +59 -0
- wog_dump/core/printprep.py +249 -0
- wog_dump/core/probe.py +187 -0
- wog_dump/core/render.py +319 -0
- wog_dump/core/scene.py +1393 -0
- wog_dump/core/scene_states.py +440 -0
- wog_dump/core/scene_steps.py +73 -0
- wog_dump/core/transforms.py +240 -0
- wog_dump/core/unpack.py +846 -0
- wog_dump/core/viewer.py +125 -0
- wog_dump/core/webapp/__init__.py +1 -0
- wog_dump/core/webapp/app.py +218 -0
- wog_dump/core/webapp/static/app.js +66 -0
- wog_dump/core/webapp/static/index.html +26 -0
- wog_dump/core/webapp/static/weapon-view.js +130 -0
- wog_dump/core/webapp/static/weapon.html +46 -0
- wog_dump/resources/__init__.py +0 -0
- wog_dump/resources/blender_setup.py +182 -0
- wog_dump/resources/locales/ru/LC_MESSAGES/wog_dump.po +52 -0
- wog_dump/resources/render_turntable.py +111 -0
- wog_dump/resources/render_video.py +133 -0
- wog_dump/resources/viewer/template.html +84 -0
- wog_dump/resources/viewer/vendor/LICENSE +21 -0
- wog_dump/resources/viewer/vendor/PATCHES.md +8 -0
- wog_dump/resources/viewer/vendor/addons/controls/OrbitControls.js +1523 -0
- wog_dump/resources/viewer/vendor/addons/loaders/GLTFLoader.js +4727 -0
- wog_dump/resources/viewer/vendor/addons/utils/BufferGeometryUtils.js +1373 -0
- wog_dump/resources/viewer/vendor/three.module.min.js +6 -0
- wog_dump/resources/viewer/viewer.js +350 -0
- wog_dump/utils/__init__.py +1 -0
- wog_dump/utils/i18n.py +78 -0
- wog_dump/utils/logging.py +603 -0
- wog_dump/utils/normal_map.py +345 -0
- wog_dump/utils/progress.py +97 -0
wog_dump/cli/auth.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Login/logout commands for the WOG Dump CLI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from ..core.auth import AuthManager
|
|
8
|
+
from .errors import error_handler
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@click.command()
|
|
12
|
+
@click.option(
|
|
13
|
+
"--email", type=str, default=None, help="Game account email (prompted when omitted)"
|
|
14
|
+
)
|
|
15
|
+
@click.option(
|
|
16
|
+
"--password",
|
|
17
|
+
type=str,
|
|
18
|
+
default=None,
|
|
19
|
+
help="Game account password (prompted when omitted)",
|
|
20
|
+
)
|
|
21
|
+
@click.pass_context
|
|
22
|
+
def login(ctx: click.Context, email: str | None, password: str | None) -> None:
|
|
23
|
+
"""Log into your World of Guns game account.
|
|
24
|
+
|
|
25
|
+
The key API only serves authenticated clients. Enter the email and
|
|
26
|
+
password of your game account (create one in-game first if you don't
|
|
27
|
+
have it yet). A fresh session is obtained automatically on every run,
|
|
28
|
+
so no sensitive data ever ships with the repository.
|
|
29
|
+
|
|
30
|
+
Alternatively, skip the account entirely and put a captured session
|
|
31
|
+
(WOG_AUTH_ID / WOG_AUTH_SESSION) into .env - see docs/mitm-capture.md.
|
|
32
|
+
"""
|
|
33
|
+
logger = ctx.obj["logger"]
|
|
34
|
+
config = ctx.obj["config"]
|
|
35
|
+
|
|
36
|
+
with error_handler("Login"):
|
|
37
|
+
if email is None:
|
|
38
|
+
email = click.prompt("Game account email")
|
|
39
|
+
if password is None:
|
|
40
|
+
password = click.prompt("Game account password", hide_input=True)
|
|
41
|
+
else:
|
|
42
|
+
logger.warning(
|
|
43
|
+
"Password given on the command line is visible in the "
|
|
44
|
+
"process list (e.g. /proc/<pid>/cmdline on shared hosts); "
|
|
45
|
+
"prefer the interactive prompt"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
auth = AuthManager(config)
|
|
49
|
+
identity = auth.login(email, password)
|
|
50
|
+
|
|
51
|
+
logger.print_status(f"Logged in as {email} (id={identity.auth_id})", "success")
|
|
52
|
+
logger.console.print(
|
|
53
|
+
"Credentials and session are stored in the local database:\n"
|
|
54
|
+
f" {config.db_path}"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@click.command()
|
|
59
|
+
@click.pass_context
|
|
60
|
+
def logout(ctx: click.Context) -> None:
|
|
61
|
+
"""Remove the stored game account credentials."""
|
|
62
|
+
logger = ctx.obj["logger"]
|
|
63
|
+
config = ctx.obj["config"]
|
|
64
|
+
|
|
65
|
+
with error_handler("Logout"):
|
|
66
|
+
AuthManager(config).logout()
|
|
67
|
+
logger.print_status(
|
|
68
|
+
f"Removed account credentials from {config.db_path}", "success"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@click.command()
|
|
73
|
+
@click.option(
|
|
74
|
+
"--name",
|
|
75
|
+
type=str,
|
|
76
|
+
default=None,
|
|
77
|
+
help="Account display name (prompted when omitted)",
|
|
78
|
+
)
|
|
79
|
+
@click.option(
|
|
80
|
+
"--email", type=str, default=None, help="Game account email (prompted when omitted)"
|
|
81
|
+
)
|
|
82
|
+
@click.option(
|
|
83
|
+
"--password",
|
|
84
|
+
type=str,
|
|
85
|
+
default=None,
|
|
86
|
+
help="Game account password (prompted when omitted)",
|
|
87
|
+
)
|
|
88
|
+
@click.pass_context
|
|
89
|
+
def register(
|
|
90
|
+
ctx: click.Context, name: str | None, email: str | None, password: str | None
|
|
91
|
+
) -> None:
|
|
92
|
+
"""Create a new World of Guns game account, then log into it.
|
|
93
|
+
|
|
94
|
+
The same email/password registration the standalone game client
|
|
95
|
+
offers (the server sends a confirmation email). After registering,
|
|
96
|
+
the account is logged in right away so key fetching works without
|
|
97
|
+
further steps.
|
|
98
|
+
"""
|
|
99
|
+
logger = ctx.obj["logger"]
|
|
100
|
+
config = ctx.obj["config"]
|
|
101
|
+
|
|
102
|
+
with error_handler("Register"):
|
|
103
|
+
if name is None:
|
|
104
|
+
name = click.prompt("Account name")
|
|
105
|
+
if email is None:
|
|
106
|
+
email = click.prompt("Game account email")
|
|
107
|
+
if password is None:
|
|
108
|
+
password = click.prompt(
|
|
109
|
+
"Game account password", hide_input=True, confirmation_prompt=True
|
|
110
|
+
)
|
|
111
|
+
else:
|
|
112
|
+
logger.warning(
|
|
113
|
+
"Password given on the command line is visible in the "
|
|
114
|
+
"process list (e.g. /proc/<pid>/cmdline on shared hosts); "
|
|
115
|
+
"prefer the interactive prompt"
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
auth = AuthManager(config)
|
|
119
|
+
auth.register(name, email, password)
|
|
120
|
+
identity = auth.login(email, password)
|
|
121
|
+
|
|
122
|
+
logger.print_status(
|
|
123
|
+
f"Registered and logged in as {email} (id={identity.auth_id})", "success"
|
|
124
|
+
)
|
|
125
|
+
logger.console.print(
|
|
126
|
+
"Credentials and session are stored in the local database:\n"
|
|
127
|
+
f" {config.db_path}"
|
|
128
|
+
)
|
wog_dump/cli/cache.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Cache management command for the WOG Dump CLI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from ..core.database import WOGDatabase
|
|
8
|
+
from ..core.download import DownloadManager
|
|
9
|
+
from .errors import error_handler, print_banner_if_standalone
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@click.command()
|
|
13
|
+
@click.option("--clear", is_flag=True, help="Clear cached weapons and keys")
|
|
14
|
+
@click.option(
|
|
15
|
+
"--migrate", is_flag=True, help="Import legacy runtime txt files into the database"
|
|
16
|
+
)
|
|
17
|
+
@click.option(
|
|
18
|
+
"--force",
|
|
19
|
+
is_flag=True,
|
|
20
|
+
help="With --migrate: re-run the one-time legacy import",
|
|
21
|
+
)
|
|
22
|
+
@click.option("--show-cache", is_flag=True, help="Show detailed database statistics")
|
|
23
|
+
@click.option(
|
|
24
|
+
"--validate-assets",
|
|
25
|
+
is_flag=True,
|
|
26
|
+
help="Validate that locally cached assets exist and are non-empty",
|
|
27
|
+
)
|
|
28
|
+
@click.pass_context
|
|
29
|
+
def cache(
|
|
30
|
+
ctx: click.Context,
|
|
31
|
+
clear: bool,
|
|
32
|
+
migrate: bool,
|
|
33
|
+
force: bool,
|
|
34
|
+
show_cache: bool,
|
|
35
|
+
validate_assets: bool,
|
|
36
|
+
) -> None:
|
|
37
|
+
"""Manage the local database (weapons, keys, account).
|
|
38
|
+
|
|
39
|
+
Data lives in a per-user SQLite database outside the repository. Use
|
|
40
|
+
--migrate to import weapons.txt/keys.txt from an older installation.
|
|
41
|
+
"""
|
|
42
|
+
logger = ctx.obj["logger"]
|
|
43
|
+
config = ctx.obj["config"]
|
|
44
|
+
|
|
45
|
+
with error_handler("Cache management"):
|
|
46
|
+
print_banner_if_standalone(ctx)
|
|
47
|
+
|
|
48
|
+
db = WOGDatabase(config)
|
|
49
|
+
|
|
50
|
+
if clear:
|
|
51
|
+
with logger.operation_context("cache_clear", "cache clear"):
|
|
52
|
+
db.clear_cached_data()
|
|
53
|
+
logger.print_status("Cached weapons and keys cleared", "success")
|
|
54
|
+
|
|
55
|
+
elif migrate:
|
|
56
|
+
with logger.operation_context("migration", "legacy import"):
|
|
57
|
+
success = db.import_legacy_txt(
|
|
58
|
+
weapons_file=config.weapons_file,
|
|
59
|
+
keys_file=config.keys_file,
|
|
60
|
+
force=force,
|
|
61
|
+
)
|
|
62
|
+
if success:
|
|
63
|
+
logger.print_status(
|
|
64
|
+
"Legacy import completed successfully", "success"
|
|
65
|
+
)
|
|
66
|
+
elif force:
|
|
67
|
+
logger.print_status("No legacy files found to import", "warning")
|
|
68
|
+
else:
|
|
69
|
+
logger.print_status(
|
|
70
|
+
"Legacy files already imported once; use --force to "
|
|
71
|
+
"import again",
|
|
72
|
+
"warning",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
elif validate_assets:
|
|
76
|
+
with logger.operation_context("asset_validation", "asset validation"):
|
|
77
|
+
weapons = db.get_weapons()
|
|
78
|
+
if not weapons:
|
|
79
|
+
logger.error("No weapons found. Run 'download-weapons' first.")
|
|
80
|
+
return
|
|
81
|
+
|
|
82
|
+
with DownloadManager(config) as downloader:
|
|
83
|
+
valid, invalid = downloader.validate_cached_assets(weapons)
|
|
84
|
+
|
|
85
|
+
if invalid:
|
|
86
|
+
logger.console.print(
|
|
87
|
+
f"\n[bold red]Invalid assets found ({len(invalid)}):[/bold red]"
|
|
88
|
+
)
|
|
89
|
+
for asset in invalid[:10]:
|
|
90
|
+
logger.console.print(f" • {asset}")
|
|
91
|
+
if len(invalid) > 10:
|
|
92
|
+
logger.console.print(f" ... and {len(invalid) - 10} more")
|
|
93
|
+
|
|
94
|
+
logger.print_status(
|
|
95
|
+
f"Validation: {len(valid)} valid, {len(invalid)} invalid",
|
|
96
|
+
"success" if len(invalid) == 0 else "warning",
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
else:
|
|
100
|
+
# Default and --show-cache: database statistics
|
|
101
|
+
stats = db.get_stats()
|
|
102
|
+
account = (
|
|
103
|
+
stats["account"]["email"] or "not logged in (run 'wog-dump login')"
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
cache_data = [
|
|
107
|
+
["Database", stats["database"]],
|
|
108
|
+
["Account", account],
|
|
109
|
+
["Weapons Count", str(stats["weapons"]["count"])],
|
|
110
|
+
["Keys Count", str(stats["keys"]["count"])],
|
|
111
|
+
["Session Updated", stats["identity"]["updated_at"] or "never"],
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
logger.print_table("Database Statistics", ["Property", "Value"], cache_data)
|
|
115
|
+
|
|
116
|
+
weapons = db.get_weapons()
|
|
117
|
+
if show_cache and weapons:
|
|
118
|
+
logger.console.print("\n[bold]Sample weapons (first 10):[/bold]")
|
|
119
|
+
for weapon in weapons[:10]:
|
|
120
|
+
has_key = "✓" if db.get_key(weapon) else "✗"
|
|
121
|
+
logger.console.print(f" {has_key} {weapon}")
|
|
122
|
+
if len(weapons) > 10:
|
|
123
|
+
logger.console.print(f" ... and {len(weapons) - 10} more")
|
wog_dump/cli/catalog.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Catalog command: per-weapon pipeline status table."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
|
|
9
|
+
from ..core.catalog import CATALOG_SCHEMA, STAGES, WeaponEntry, build_catalog
|
|
10
|
+
from ..utils.i18n import t, tn
|
|
11
|
+
from .errors import error_handler, print_banner_if_standalone
|
|
12
|
+
|
|
13
|
+
STATUS_CHOICES = STAGES + ("previews",)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _human_size(size_bytes: int) -> str:
|
|
17
|
+
if size_bytes <= 0:
|
|
18
|
+
return "-"
|
|
19
|
+
units = ("B", "KB", "MB", "GB")
|
|
20
|
+
value = float(size_bytes)
|
|
21
|
+
for unit in units:
|
|
22
|
+
if value < 1024 or unit == units[-1]:
|
|
23
|
+
return f"{value:.0f} {unit}" if unit == "B" else f"{value:.1f} {unit}"
|
|
24
|
+
value /= 1024
|
|
25
|
+
return "-"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _apply_filters(
|
|
29
|
+
entries: list[WeaponEntry],
|
|
30
|
+
filter_text: str | None,
|
|
31
|
+
status: str | None,
|
|
32
|
+
) -> list[WeaponEntry]:
|
|
33
|
+
if filter_text:
|
|
34
|
+
needle = filter_text.lower()
|
|
35
|
+
entries = [e for e in entries if needle in e.name.lower()]
|
|
36
|
+
if status:
|
|
37
|
+
entries = [e for e in entries if getattr(e, status)]
|
|
38
|
+
return entries
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _sort_entries(
|
|
42
|
+
entries: list[WeaponEntry], sort_key: str, reverse: bool
|
|
43
|
+
) -> list[WeaponEntry]:
|
|
44
|
+
if sort_key == "name":
|
|
45
|
+
entries.sort(key=lambda e: e.name, reverse=reverse)
|
|
46
|
+
elif sort_key == "size":
|
|
47
|
+
entries.sort(key=lambda e: (e.size_bytes, e.name), reverse=reverse)
|
|
48
|
+
elif sort_key == "status":
|
|
49
|
+
entries.sort(key=lambda e: (-e.stages_passed, e.name), reverse=reverse)
|
|
50
|
+
return entries
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _entries_to_json(entries: list[WeaponEntry]) -> dict:
|
|
54
|
+
return {
|
|
55
|
+
"schema": CATALOG_SCHEMA,
|
|
56
|
+
"count": len(entries),
|
|
57
|
+
"weapons": [
|
|
58
|
+
{
|
|
59
|
+
"name": e.name,
|
|
60
|
+
"has_key": e.has_key,
|
|
61
|
+
"downloaded": e.downloaded,
|
|
62
|
+
"decrypted": e.decrypted,
|
|
63
|
+
"unpacked": e.unpacked,
|
|
64
|
+
"scene": e.scene,
|
|
65
|
+
"previews": e.previews,
|
|
66
|
+
"size_bytes": e.size_bytes,
|
|
67
|
+
}
|
|
68
|
+
for e in entries
|
|
69
|
+
],
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@click.command("catalog")
|
|
74
|
+
@click.option(
|
|
75
|
+
"--filter", "filter_text", metavar="TEXT", help="Case-insensitive name substring"
|
|
76
|
+
)
|
|
77
|
+
@click.option(
|
|
78
|
+
"--status",
|
|
79
|
+
type=click.Choice(STATUS_CHOICES),
|
|
80
|
+
help="Only weapons that passed the stage (key, downloaded, decrypted, "
|
|
81
|
+
"unpacked, scene, previews)",
|
|
82
|
+
)
|
|
83
|
+
@click.option(
|
|
84
|
+
"--sort",
|
|
85
|
+
"sort_key",
|
|
86
|
+
type=click.Choice(("name", "size", "status")),
|
|
87
|
+
default="name",
|
|
88
|
+
show_default=True,
|
|
89
|
+
help="Sort column",
|
|
90
|
+
)
|
|
91
|
+
@click.option("--reverse", is_flag=True, default=False, help="Reverse the sort order")
|
|
92
|
+
@click.option(
|
|
93
|
+
"--limit", type=int, default=None, metavar="N", help="Show the first N rows"
|
|
94
|
+
)
|
|
95
|
+
@click.option(
|
|
96
|
+
"--json", "as_json", is_flag=True, default=False, help="Machine-readable output"
|
|
97
|
+
)
|
|
98
|
+
@click.pass_context
|
|
99
|
+
def catalog(
|
|
100
|
+
ctx: click.Context,
|
|
101
|
+
filter_text: str | None,
|
|
102
|
+
status: str | None,
|
|
103
|
+
sort_key: str,
|
|
104
|
+
reverse: bool,
|
|
105
|
+
limit: int | None,
|
|
106
|
+
as_json: bool,
|
|
107
|
+
) -> None:
|
|
108
|
+
"""List every weapon with its pipeline status.
|
|
109
|
+
|
|
110
|
+
Reads the local database and runtime folders only, no network.
|
|
111
|
+
|
|
112
|
+
\b
|
|
113
|
+
Examples:
|
|
114
|
+
wog-dump catalog
|
|
115
|
+
wog-dump catalog --filter ak --status decrypted
|
|
116
|
+
wog-dump catalog --sort size --limit 20
|
|
117
|
+
wog-dump catalog --json
|
|
118
|
+
"""
|
|
119
|
+
logger = ctx.obj["logger"]
|
|
120
|
+
|
|
121
|
+
with error_handler("Catalog"):
|
|
122
|
+
print_banner_if_standalone(ctx)
|
|
123
|
+
config = ctx.obj["config"]
|
|
124
|
+
|
|
125
|
+
entries = build_catalog(config)
|
|
126
|
+
if not entries:
|
|
127
|
+
logger.print_status(
|
|
128
|
+
t("Catalog is empty: run 'wog-dump download-weapons' first"),
|
|
129
|
+
"warning",
|
|
130
|
+
)
|
|
131
|
+
return
|
|
132
|
+
|
|
133
|
+
entries = _apply_filters(entries, filter_text, status)
|
|
134
|
+
entries = _sort_entries(entries, sort_key, reverse)
|
|
135
|
+
total = len(entries)
|
|
136
|
+
if limit is not None:
|
|
137
|
+
entries = entries[: max(limit, 0)]
|
|
138
|
+
|
|
139
|
+
if as_json:
|
|
140
|
+
payload = _entries_to_json(entries)
|
|
141
|
+
payload["total"] = total
|
|
142
|
+
click.echo(json.dumps(payload, indent=2))
|
|
143
|
+
return
|
|
144
|
+
|
|
145
|
+
if not entries:
|
|
146
|
+
logger.print_status(t("No weapons match the filters"), "warning")
|
|
147
|
+
return
|
|
148
|
+
|
|
149
|
+
rows = [
|
|
150
|
+
[
|
|
151
|
+
e.name,
|
|
152
|
+
"key" if e.has_key else "-",
|
|
153
|
+
"dl" if e.downloaded else "-",
|
|
154
|
+
"dec" if e.decrypted else "-",
|
|
155
|
+
"unp" if e.unpacked else "-",
|
|
156
|
+
"scene" if e.scene else "-",
|
|
157
|
+
"prev" if e.previews else "-",
|
|
158
|
+
_human_size(e.size_bytes),
|
|
159
|
+
]
|
|
160
|
+
for e in entries
|
|
161
|
+
]
|
|
162
|
+
shown = f"{len(entries)} of {total}" if len(entries) != total else str(total)
|
|
163
|
+
logger.print_table(
|
|
164
|
+
f"Catalog ({shown})",
|
|
165
|
+
["Weapon", "Key", "DL", "DEC", "UNP", "Scene", "Prev", "Size"],
|
|
166
|
+
rows,
|
|
167
|
+
)
|
wog_dump/cli/convert.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Normal map conversion command for the WOG Dump CLI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
|
|
10
|
+
from ..utils.normal_map import NormalMapConverter
|
|
11
|
+
from .errors import error_handler, print_banner_if_standalone
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@click.command()
|
|
15
|
+
@click.argument("path", type=click.Path(exists=True, path_type=Path))
|
|
16
|
+
@click.option("--recursive", "-r", is_flag=True, help="Process directories recursively")
|
|
17
|
+
@click.option("--backup", "-b", is_flag=True, help="Create backups before conversion")
|
|
18
|
+
@click.option(
|
|
19
|
+
"--pattern",
|
|
20
|
+
default="*.png",
|
|
21
|
+
help="File pattern to match; only swizzled normal maps are converted",
|
|
22
|
+
)
|
|
23
|
+
@click.pass_context
|
|
24
|
+
def convert_normals(
|
|
25
|
+
ctx: click.Context, path: Path, recursive: bool, backup: bool, pattern: str
|
|
26
|
+
) -> int:
|
|
27
|
+
"""Convert Unity normal maps to standard format with batch processing.
|
|
28
|
+
|
|
29
|
+
Converts Unity's normal map format (data in green/alpha channels) to
|
|
30
|
+
standard format (data in red/green channels) for compatibility with
|
|
31
|
+
other 3D applications.
|
|
32
|
+
"""
|
|
33
|
+
logger = ctx.obj["logger"]
|
|
34
|
+
|
|
35
|
+
with error_handler("Normal map conversion"):
|
|
36
|
+
print_banner_if_standalone(ctx)
|
|
37
|
+
nested = bool(ctx.obj.get("pipeline_nested"))
|
|
38
|
+
|
|
39
|
+
converter = NormalMapConverter()
|
|
40
|
+
|
|
41
|
+
converted = 0
|
|
42
|
+
with logger.operation_context("normal_conversion", "normal map conversion"):
|
|
43
|
+
if path.is_file():
|
|
44
|
+
output_path = converter.convert_normal_map(path)
|
|
45
|
+
converted = 1
|
|
46
|
+
if not nested:
|
|
47
|
+
logger.print_status(f"Converted: {output_path}", "success")
|
|
48
|
+
elif path.is_dir():
|
|
49
|
+
converted_files = converter.batch_convert_directory(
|
|
50
|
+
path, recursive=recursive, pattern=pattern, backup=backup
|
|
51
|
+
)
|
|
52
|
+
converted = len(converted_files)
|
|
53
|
+
if not nested:
|
|
54
|
+
logger.print_status(f"Converted {converted} normal maps", "success")
|
|
55
|
+
else:
|
|
56
|
+
logger.error(f"Invalid path: {path}")
|
|
57
|
+
sys.exit(1)
|
|
58
|
+
|
|
59
|
+
return converted
|
wog_dump/cli/decrypt.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""Decrypt command for the WOG Dump CLI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
import UnityPy
|
|
10
|
+
|
|
11
|
+
from ..core.decrypt import AssetDecryptor
|
|
12
|
+
from ..core.keys import KeyManager
|
|
13
|
+
from ..utils.logging import get_logger
|
|
14
|
+
from .download import _load_weapon_list, _update_keys
|
|
15
|
+
from .errors import error_handler, print_banner_if_standalone
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@click.command()
|
|
19
|
+
@click.option(
|
|
20
|
+
"--update-keys", is_flag=True, help="Update decryption keys before decrypting"
|
|
21
|
+
)
|
|
22
|
+
@click.option(
|
|
23
|
+
"--weapons", type=str, help="Comma-separated list of specific weapons to decrypt"
|
|
24
|
+
)
|
|
25
|
+
@click.option(
|
|
26
|
+
"--validate", is_flag=True, help="Validate decrypted files after processing"
|
|
27
|
+
)
|
|
28
|
+
@click.pass_context
|
|
29
|
+
def decrypt_assets(
|
|
30
|
+
ctx: click.Context, update_keys: bool, weapons: str | None, validate: bool
|
|
31
|
+
) -> tuple[list[Path], list[str]]:
|
|
32
|
+
"""Decrypt downloaded assets using fetched keys.
|
|
33
|
+
|
|
34
|
+
Uses XOR decryption with MD5-derived keys to decrypt Unity assets
|
|
35
|
+
into usable format for unpacking.
|
|
36
|
+
"""
|
|
37
|
+
logger = ctx.obj["logger"]
|
|
38
|
+
config = ctx.obj["config"]
|
|
39
|
+
|
|
40
|
+
with error_handler("Asset decryption"):
|
|
41
|
+
print_banner_if_standalone(ctx)
|
|
42
|
+
nested = bool(ctx.obj.get("pipeline_nested"))
|
|
43
|
+
|
|
44
|
+
weapon_list = _load_weapon_list(config, weapons)
|
|
45
|
+
|
|
46
|
+
# Manage decryption keys
|
|
47
|
+
key_manager = KeyManager(config)
|
|
48
|
+
if update_keys:
|
|
49
|
+
keys = _update_keys(config, weapon_list)
|
|
50
|
+
if keys is None:
|
|
51
|
+
keys = key_manager.load_keys()
|
|
52
|
+
else:
|
|
53
|
+
keys = key_manager.load_keys()
|
|
54
|
+
|
|
55
|
+
if not keys:
|
|
56
|
+
logger.error("No decryption keys found. Use --update-keys to fetch them.")
|
|
57
|
+
sys.exit(1)
|
|
58
|
+
|
|
59
|
+
# Decrypt assets
|
|
60
|
+
results: tuple[list[Path], list[str]] = ([], [])
|
|
61
|
+
with logger.operation_context("decryption", "asset decryption"):
|
|
62
|
+
decryptor = AssetDecryptor(config)
|
|
63
|
+
decrypted_files, failed_assets = decryptor.decrypt_all_assets(
|
|
64
|
+
keys, weapons=weapon_list if weapons else None
|
|
65
|
+
)
|
|
66
|
+
results = (decrypted_files, failed_assets)
|
|
67
|
+
|
|
68
|
+
if validate:
|
|
69
|
+
with logger.operation_context("validation", "file validation"):
|
|
70
|
+
validation_failures = validate_decrypted_files(decrypted_files)
|
|
71
|
+
if validation_failures:
|
|
72
|
+
logger.warning(
|
|
73
|
+
f"Validation failed for {len(validation_failures)} files"
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
if not nested:
|
|
77
|
+
logger.print_status(
|
|
78
|
+
f"Decrypted {len(decrypted_files)} files", "success"
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
if failed_assets:
|
|
82
|
+
logger.print_status(
|
|
83
|
+
f"Failed to decrypt {len(failed_assets)} assets", "error"
|
|
84
|
+
)
|
|
85
|
+
if config.strict_mode:
|
|
86
|
+
sys.exit(1)
|
|
87
|
+
|
|
88
|
+
return results
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def validate_decrypted_files(files: list[Path]) -> list[Path]:
|
|
92
|
+
"""Validate decrypted files and return the list of validation failures."""
|
|
93
|
+
logger = get_logger()
|
|
94
|
+
validation_failures = []
|
|
95
|
+
|
|
96
|
+
with logger.create_task_progress() as progress:
|
|
97
|
+
task = progress.add_task("Validating files", total=len(files))
|
|
98
|
+
|
|
99
|
+
for file_path in files:
|
|
100
|
+
try:
|
|
101
|
+
if not file_path.exists() or file_path.stat().st_size == 0:
|
|
102
|
+
validation_failures.append(file_path)
|
|
103
|
+
continue
|
|
104
|
+
|
|
105
|
+
# Try to load as a Unity asset for additional validation
|
|
106
|
+
try:
|
|
107
|
+
env = UnityPy.load(str(file_path))
|
|
108
|
+
if not env.objects:
|
|
109
|
+
validation_failures.append(file_path)
|
|
110
|
+
except Exception:
|
|
111
|
+
validation_failures.append(file_path)
|
|
112
|
+
|
|
113
|
+
except Exception:
|
|
114
|
+
validation_failures.append(file_path)
|
|
115
|
+
|
|
116
|
+
progress.update(task, advance=1)
|
|
117
|
+
|
|
118
|
+
return validation_failures
|