You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.7 KiB
Python
67 lines
2.7 KiB
Python
import os
|
|
import urllib.request
|
|
from pymxs import runtime as rt
|
|
|
|
# ==========================================
|
|
# CONFIGURAÇÕES DO GITEA - IMMERSE GAMES
|
|
# ==========================================
|
|
# URL apontando para a pasta 'instalador'
|
|
GITEA_RAW_URL = "https://git.immersegame.com/vr4life_public/vr4life-3dmax-plugin/raw/branch/main/"
|
|
GITEA_TOKEN = "3831a0da2f87e391f41f4649d48498136a1903c9"
|
|
|
|
# Descobre a pasta segura de Scripts do Usuário do próprio 3ds Max
|
|
user_scripts_dir = rt.getDir(rt.name("userScripts"))
|
|
PLUGIN_DIR = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
|
|
|
|
FILES_TO_DOWNLOAD = [
|
|
"vr4life_ui.py",
|
|
"vr4life_engine.py",
|
|
"vr4life_cloud.py",
|
|
"run_vr4life.py",
|
|
"vr4life_updater.py",
|
|
"install_vr4life.py",
|
|
"version.txt"
|
|
]
|
|
|
|
def install_from_cloud():
|
|
rt.clearListener()
|
|
print("=== INICIANDO INSTALAÇÃO ONLINE ===")
|
|
|
|
# 1. Cria a pasta do plugin dentro do 3ds Max se ela não existir
|
|
if not os.path.exists(PLUGIN_DIR):
|
|
os.makedirs(PLUGIN_DIR)
|
|
print(f"Pasta de destino criada: {PLUGIN_DIR}")
|
|
|
|
# 2. Inicia o download forçando o token na URL
|
|
try:
|
|
for file_name in FILES_TO_DOWNLOAD:
|
|
# INJEÇÃO DIRETA: O token vai na própria URL para evitar bloqueio do Gitea nas rotas Raw
|
|
remote_url = f"{GITEA_RAW_URL}{file_name}?token={GITEA_TOKEN}"
|
|
local_path = os.path.join(PLUGIN_DIR, file_name).replace("\\", "/")
|
|
|
|
print(f"Baixando: {file_name}...")
|
|
|
|
req = urllib.request.Request(remote_url)
|
|
# Mantemos o cabeçalho Bearer como redundância de segurança
|
|
#req.add_header("Authorization", f"Bearer {GITEA_TOKEN}")
|
|
req.add_header("Authorization", "token " +GITEA_TOKEN )
|
|
# Executa o download e salva no PC
|
|
response = urllib.request.urlopen(req)
|
|
remote_code = response.read().decode('utf-8')
|
|
|
|
with open(local_path, "w", encoding="utf-8") as f:
|
|
f.write(remote_code)
|
|
|
|
print("Download concluído! Configurando menu do 3ds Max...")
|
|
|
|
# 3. Executa o instalador local (que ele acabou de baixar) para montar o menu
|
|
install_script = os.path.join(PLUGIN_DIR, "install_vr4life.py").replace("\\", "/")
|
|
rt.python.ExecuteFile(install_script)
|
|
|
|
except Exception as e:
|
|
msg = f"Erro ao baixar os arquivos do Gitea.\nVerifique a internet, URL ou o Token de acesso.\n\nDetalhe técnico: {str(e)}"
|
|
rt.messageBox(msg, title="Erro de Instalação")
|
|
print(msg)
|
|
|
|
if __name__ == "__main__":
|
|
install_from_cloud() |