-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_everything.py
More file actions
214 lines (189 loc) · 6.68 KB
/
build_everything.py
File metadata and controls
214 lines (189 loc) · 6.68 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/usr/bin/env python3
"""
Indexador universal — lê TODOS os PNGs do workspace e gera
data/everything.json + copia imagens pra static/everything/.
Uso: rodar depois de build_catalog.py.
"""
import json
import hashlib
from pathlib import Path
ROOT = Path("/home/user/workspace")
OUT = Path("/home/user/workspace/slotforge_catalog/data/everything.json")
STATIC_ALL = Path("/home/user/workspace/slotforge_catalog/static/everything")
STATIC_ALL.mkdir(parents=True, exist_ok=True)
# Pastas a excluir (agent outputs internos)
EXCLUDE_DIRS = {
"__pycache__",
"node_modules",
".git",
"slotforge_catalog", # evita auto-indexar
}
# Max size pra copiar pra static (imagens gigantes viram problema de deploy)
MAX_SIZE_MB = 15
def should_include(p: Path) -> bool:
parts = set(p.parts)
if parts & EXCLUDE_DIRS:
return False
# Ignorar fullres gigantes se existir versão normal
if p.stat().st_size > MAX_SIZE_MB * 1024 * 1024:
return False
return True
def short_hash(s: str) -> str:
return hashlib.md5(s.encode()).hexdigest()[:8]
def categorize(rel_path: str) -> str:
"""Categoria leve baseada no caminho."""
rl = rel_path.lower()
# Heroes/hero_clean ainda são úteis distinguir
if "hero_clean" in rl or "/top10" in rl or "tgs_reimagined" in rl:
return "Hero 1x5 (MadLab)"
if "pipeline_bison_express" in rl or "bison_express" in rl:
return "Bison Express"
if "pipeline_thunder_drum_wyrm" in rl or "pipeline_v2_thunder_drum_wyrm" in rl or "pipeline_seq_thunder" in rl:
return "Thunder Drum Wyrm"
if "heroes_official" in rl:
return "Coin Baron Official"
if "pigs_of_olympus" in rl or "pigs_olympus" in rl:
if "/characters" in rl or "character" in rl:
return "Pigs of Olympus — Characters"
if "/bonus" in rl:
return "Pigs of Olympus — Bonus"
if "/symbols" in rl or "sym_" in rl:
return "Pigs of Olympus — Symbols"
return "Pigs of Olympus"
if "mystic_throne" in rl or "mystic_playable" in rl:
return "Mystic Throne"
if "coin_baron" in rl:
return "Coin Baron"
if "slotforge_data/hero_images" in rl:
return "SlotForge hero_images (histórico)"
if "slotforge_data/symbols" in rl:
return "SlotForge symbols"
if "references_library" in rl or "image_vault" in rl:
return "References (refs externas)"
if "slotforge_data/base_game_screens" in rl:
return "Base game screens"
if "slotforge_data/fullscreen" in rl:
return "Fullscreen v1"
if "slotforge_gallery/assets" in rl:
return "Gallery assets"
if "slotforge_gallery/mockups_with_hands" in rl:
return "Mockups with hands"
if "tgs_reference" in rl:
return "TGS reference"
if "tool_calls" in rl:
return "Tool calls (AI gen)"
if "phase2_mystic_throne/assets" in rl or "phase2_mystic_throne/modern_refs" in rl:
return "Mystic Throne assets/refs"
if "phase2_mystic_throne" in rl:
return "Phase 2 outros"
if "forgingslots" in rl:
return "Forging Slots outputs"
return "Outros"
def classify_format(filename: str, rel_path: str) -> str:
"""Form-factor bucket para filtro."""
hay = (filename + " " + rel_path).lower()
if "pulltab" in hay:
return "pulltab"
if "cabinet" in hay or "gabinete" in hay:
return "cabinet"
if "ipad" in hay and "landscape" in hay:
return "ipad_landscape"
if "ipad" in hay and "portrait" in hay:
return "ipad_portrait"
if "ipad" in hay:
return "ipad"
if "mobile" in hay and "landscape" in hay:
return "mobile_landscape"
if "mobile" in hay and "portrait" in hay:
return "mobile_portrait"
if "mobile" in hay:
return "mobile"
if "web" in hay:
return "web"
if "portrait" in hay or "9_16" in hay or "9x16" in hay:
return "portrait"
if "landscape" in hay or "16_9" in hay or "16x9" in hay:
return "landscape"
if "symbol" in hay or "sym_" in hay:
return "symbol"
if "character" in hay or "char" in hay or "mascot" in hay:
return "character"
if "bonus" in hay:
return "bonus"
if "logo" in hay:
return "logo"
if "bg_" in hay or "background" in hay:
return "background"
return "other"
def main():
all_pngs = []
for p in ROOT.rglob("*.png"):
try:
if not should_include(p):
continue
rel = p.relative_to(ROOT)
rel_str = str(rel)
# Filtros
parts = set(rel.parts)
if parts & EXCLUDE_DIRS:
continue
all_pngs.append(p)
except Exception:
continue
print(f"Encontrados: {len(all_pngs)} PNGs")
entries = []
copy_errors = 0
for src in all_pngs:
rel = src.relative_to(ROOT)
rel_str = str(rel)
# ID estável baseado em path
id_hash = short_hash(rel_str)
ext = src.suffix.lower()
dst_name = f"{id_hash}_{src.stem[:40]}{ext}"
dst = STATIC_ALL / dst_name
try:
if not dst.exists() or dst.stat().st_mtime < src.stat().st_mtime:
dst.write_bytes(src.read_bytes())
except Exception as e:
copy_errors += 1
continue
category = categorize(rel_str)
fmt = classify_format(src.name, rel_str)
size_kb = src.stat().st_size // 1024
entries.append({
"id": f"all_{id_hash}",
"filename": src.name,
"rel_path": rel_str,
"category": category,
"format_class": fmt,
"size_kb": size_kb,
"image_url": f"/static/everything/{dst_name}",
})
# Stats
cat_counts = {}
fmt_counts = {}
for e in entries:
cat_counts[e["category"]] = cat_counts.get(e["category"], 0) + 1
fmt_counts[e["format_class"]] = fmt_counts.get(e["format_class"], 0) + 1
doc = {
"generated_at": "2026-04-20",
"total": len(entries),
"copy_errors": copy_errors,
"by_category": cat_counts,
"by_format": fmt_counts,
"items": entries,
}
OUT.parent.mkdir(parents=True, exist_ok=True)
with open(OUT, "w") as f:
json.dump(doc, f, indent=2, ensure_ascii=False)
print(f"Escrito: {OUT}")
print(f"Total indexado: {len(entries)}")
print(f"Erros de cópia: {copy_errors}")
print("\nPor categoria:")
for c, n in sorted(cat_counts.items(), key=lambda x: -x[1]):
print(f" {n:4d} {c}")
print("\nPor form-factor:")
for f, n in sorted(fmt_counts.items(), key=lambda x: -x[1]):
print(f" {n:4d} {f}")
if __name__ == "__main__":
main()