1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Fuse's combine step in Python: sticker layer from A, effect layer from B. The two
jsons and their trust tokens are copied byte for byte (never touched). The unsigned
overridden_metadata is copied from A but its pack name/publisher are reset to "Fuse"
(the originals name the source pack, in whatever language).
usage: mix.py A.was B.was OUT.was"""
import json, sys, zipfile
a, b, out = (zipfile.ZipFile(sys.argv[1]), zipfile.ZipFile(sys.argv[2]), sys.argv[3])
M, E, T, META = "animation/animation.json", "animation/animation_secondary.json", ".trust_token", "animation/animation.json.overridden_metadata"
def clean_meta(raw):
try:
o = json.loads(raw)
except Exception:
return raw
if "sticker-pack-name" in o:
o["sticker-pack-name"] = "Fuse"
if "sticker-pack-publisher" in o:
o["sticker-pack-publisher"] = "Fuse"
return json.dumps(o).encode()
with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as z:
z.writestr("animation/", b"")
for name, src in [(M, a), (E, b), (M + T, a), (E + T, b)]:
z.writestr(name, src.read(name))
z.writestr(META, clean_meta(a.read(META)))
print(out)