Cnass commited on
Commit
dfb6aa6
·
verified ·
1 Parent(s): f9c7630

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -0
app.py CHANGED
@@ -207,3 +207,64 @@ async def download_file(job_id: str):
207
  job = jobs.get(job_id)
208
  if not job or job.get("status") != "completed": return JSONResponse(status_code=400, content={"error": "Dosya hazır değil"})
209
  return FileResponse(job["file_path"], media_type="application/octet-stream", filename=job["filename"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  job = jobs.get(job_id)
208
  if not job or job.get("status") != "completed": return JSONResponse(status_code=400, content={"error": "Dosya hazır değil"})
209
  return FileResponse(job["file_path"], media_type="application/octet-stream", filename=job["filename"])
210
+
211
+ @app.post("/check_errors")
212
+ async def check_errors(mod_zip: UploadFile = File(...)):
213
+ temp_dir = tempfile.mkdtemp()
214
+ zip_path = os.path.join(temp_dir, mod_zip.filename)
215
+ with open(zip_path, "wb") as f: f.write(await mod_zip.read())
216
+
217
+ report_lines = ["=== SİSTEM KODU ÇEVİRİSİ HATA TARAMA RAPORU ===\n"]
218
+ report_lines.append("Aşağıdaki listede bulunan çeviriler, oyunun çökmesine sebep olan 'Sistem Kodları' olabilir.")
219
+ report_lines.append("Lütfen bu dosyalara girip, bu kelimeleri tekrar orijinal (İngilizce) haline geri döndürün.\n")
220
+
221
+ error_count = 0
222
+
223
+ with zipfile.ZipFile(zip_path, 'r') as zipf:
224
+ for file_info in zipf.infolist():
225
+ filename = file_info.filename
226
+ if "__MACOSX" in filename or filename.split("/")[-1].startswith("._"): continue
227
+
228
+ if filename.endswith(".json"):
229
+ try:
230
+ content = zipf.read(filename)
231
+ translations = json.loads(content.decode('utf-8'))
232
+ file_suspects = []
233
+
234
+ for orig, trans in translations.items():
235
+ if orig != trans: # Sadece çevrilmiş olanları kontrol et
236
+ is_system = False
237
+
238
+ # 1. Kural: Cümlede hiç boşluk yoksa büyük ihtimalle koddur (Örn: PlayerSpawnPoint)
239
+ if " " not in orig and len(orig) > 2: is_system = True
240
+
241
+ # 2. Kural: Alt tire içeriyorsa koddur (Örn: bg_sky_01)
242
+ if "_" in orig: is_system = True
243
+
244
+ # 3. Kural: Dosya yolu içeriyorsa koddur (Örn: Assets/Sprites/hero)
245
+ if "/" in orig or "\\" in orig: is_system = True
246
+
247
+ if is_system:
248
+ file_suspects.append(f" [RİSKLİ] Orijinal: '{orig}'\n Çevirin: '{trans}'\n")
249
+
250
+ if file_suspects:
251
+ report_lines.append(f"--------------------------------------------------")
252
+ report_lines.append(f"DOSYA: {filename}")
253
+ report_lines.append(f"--------------------------------------------------")
254
+ report_lines.extend(file_suspects)
255
+ error_count += len(file_suspects)
256
+ except:
257
+ pass
258
+
259
+ if error_count == 0:
260
+ report_lines.append("\nHarika! Görünürde hiçbir sistem kodunu çevirmemişsin. Çökme sebebi başka olabilir.")
261
+ else:
262
+ report_lines.append(f"\n==================================================")
263
+ report_lines.append(f"TOPLAM BULUNAN RİSKLİ ÇEVİRİ: {error_count} ADET")
264
+ report_lines.append(f"==================================================")
265
+
266
+ report_path = os.path.join(temp_dir, "hata_raporu.txt")
267
+ with open(report_path, "w", encoding="utf-8") as f:
268
+ f.write("\n".join(report_lines))
269
+
270
+ return FileResponse(report_path, media_type="text/plain", filename="hata_raporu.txt")