Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,50 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import shutil
|
| 3 |
-
import subprocess
|
| 4 |
import os
|
| 5 |
|
| 6 |
UPLOAD_FOLDER = "./uploads/"
|
| 7 |
-
APK_OUTPUT_FOLDER = "./output_apk/"
|
| 8 |
-
|
| 9 |
-
# Ensure directories exist
|
| 10 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
| 11 |
-
os.makedirs(APK_OUTPUT_FOLDER, exist_ok=True)
|
| 12 |
|
| 13 |
-
def
|
| 14 |
-
# Save EXE file
|
| 15 |
exe_path = os.path.join(UPLOAD_FOLDER, file.name)
|
| 16 |
shutil.copyfile(file.name, exe_path)
|
| 17 |
-
|
| 18 |
-
# Step 1: Extract assets using AssetRipper
|
| 19 |
-
assetripper_command = f"AssetRipperConsole {exe_path} -o ./unity_project"
|
| 20 |
-
subprocess.run(assetripper_command, shell=True)
|
| 21 |
-
|
| 22 |
-
# Step 2: Build APK using Unity CLI
|
| 23 |
-
unity_command = (
|
| 24 |
-
"Unity -batchmode -nographics -quit "
|
| 25 |
-
"-projectPath ./unity_project "
|
| 26 |
-
"-executeMethod BuildScript.PerformBuild"
|
| 27 |
-
)
|
| 28 |
-
subprocess.run(unity_command, shell=True)
|
| 29 |
-
|
| 30 |
-
# Path to the generated APK
|
| 31 |
-
apk_path = os.path.join(APK_OUTPUT_FOLDER, "converted_app.apk")
|
| 32 |
|
| 33 |
-
|
| 34 |
-
if os.path.exists(apk_path):
|
| 35 |
-
return apk_path
|
| 36 |
-
else:
|
| 37 |
-
return "Error: APK conversion failed."
|
| 38 |
|
| 39 |
# Gradio Interface
|
| 40 |
with gr.Blocks() as app:
|
| 41 |
-
gr.Markdown("## EXE to APK Converter")
|
| 42 |
|
| 43 |
with gr.Row():
|
| 44 |
upload_button = gr.UploadButton("Upload EXE File", file_types=[".exe"])
|
| 45 |
|
| 46 |
-
output = gr.
|
| 47 |
|
| 48 |
-
upload_button.upload(
|
| 49 |
|
| 50 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import shutil
|
|
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
UPLOAD_FOLDER = "./uploads/"
|
|
|
|
|
|
|
|
|
|
| 6 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
|
|
|
| 7 |
|
| 8 |
+
def upload_exe(file):
|
|
|
|
| 9 |
exe_path = os.path.join(UPLOAD_FOLDER, file.name)
|
| 10 |
shutil.copyfile(file.name, exe_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
return "File uploaded successfully. Please wait for manual processing."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Gradio Interface
|
| 15 |
with gr.Blocks() as app:
|
| 16 |
+
gr.Markdown("## EXE to APK Converter (External Processing)")
|
| 17 |
|
| 18 |
with gr.Row():
|
| 19 |
upload_button = gr.UploadButton("Upload EXE File", file_types=[".exe"])
|
| 20 |
|
| 21 |
+
output = gr.Textbox()
|
| 22 |
|
| 23 |
+
upload_button.upload(upload_exe, upload_button, output)
|
| 24 |
|
| 25 |
app.launch()
|