-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_manifest.py
More file actions
70 lines (56 loc) · 2.2 KB
/
generate_manifest.py
File metadata and controls
70 lines (56 loc) · 2.2 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import json
import os
from pathlib import Path
# Configuration
DIST_DIR = Path('./static/dist')
MANIFEST_FILE = 'contents.json'
MAX_STICKERS_PER_PACK = 30
def generate_whatsapp_manifest():
if not DIST_DIR.exists():
print("Error: /dist directory not found.")
return
# Get all webp files and sort them to maintain order
stickers = sorted([f.name for f in DIST_DIR.glob('*.webp')])
total_stickers = len(stickers)
if total_stickers == 0:
print("No stickers found in /dist.")
return
# Chunk the stickers into groups of 30
chunks = [stickers[i:i + MAX_STICKERS_PER_PACK] for i in range(0, total_stickers, MAX_STICKERS_PER_PACK)]
sticker_packs = []
for index, chunk in enumerate(chunks):
pack_id = str(index + 1)
# Build the sticker array for this specific chunk
pack_stickers = []
for sticker_file in chunk:
pack_stickers.append({
"image_file": sticker_file,
"emojis": ["🔥", "😎"] # WhatsApp requires at least one emoji per sticker
})
# Build the pack metadata
pack_data = {
"identifier": pack_id,
"name": f"Sticker Vault Vol. {pack_id}",
"publisher": "Indiser",
"tray_image_file": f"tray_{pack_id}.png", # Critical requirement
"image_data_version": "1",
"avoid_cache": False,
"publisher_email": "",
"publisher_website": "",
"privacy_policy_website": "",
"license_agreement_website": "",
"stickers": pack_stickers
}
sticker_packs.append(pack_data)
# Wrap in the final WhatsApp schema
final_json = {
"android_play_store_link": "",
"ios_app_store_link": "",
"sticker_packs": sticker_packs
}
# Export
with open(MANIFEST_FILE, 'w', encoding="utf-8") as f:
json.dump(final_json, f, indent=2, ensure_ascii=False)
print(f"Success. Generated contents.json with {len(chunks)} packs for {total_stickers} total stickers.")
if __name__ == '__main__':
generate_whatsapp_manifest()