Tu Nombre commited on
Commit
3e76a85
·
1 Parent(s): 104855b

descargar token al arrancar

Browse files
Files changed (2) hide show
  1. cliente_template.py +9 -0
  2. main.py +1 -1
cliente_template.py CHANGED
@@ -14,6 +14,15 @@ from moviepy.editor import VideoFileClip, AudioFileClip, TextClip, CompositeVide
14
 
15
  NICHO = "NICHO_PLACEHOLDER"
16
  CLIENT_EMAIL = "EMAIL_PLACEHOLDER"
 
 
 
 
 
 
 
 
 
17
  GROQ_KEY = "GROQ_PLACEHOLDER"
18
  PEXELS_KEY = "PEXELS_PLACEHOLDER"
19
  LOGS = []
 
14
 
15
  NICHO = "NICHO_PLACEHOLDER"
16
  CLIENT_EMAIL = "EMAIL_PLACEHOLDER"
17
+ HF_REPO = "REPO_PLACEHOLDER"
18
+
19
+ # Descargar token.json del repo si existe
20
+ try:
21
+ import urllib.request
22
+ urllib.request.urlretrieve(f"https://huggingface.co/spaces/{HF_REPO}/resolve/main/token.json", "token.json")
23
+ print("Token descargado", flush=True)
24
+ except Exception as e:
25
+ print(f"Sin token aún: {e}", flush=True)
26
  GROQ_KEY = "GROQ_PLACEHOLDER"
27
  PEXELS_KEY = "PEXELS_PLACEHOLDER"
28
  LOGS = []
main.py CHANGED
@@ -107,7 +107,7 @@ async def crear_space(nicho: str, email: str) -> str:
107
  headers = {"Authorization": f"Bearer {token_actual}", "Content-Type": "application/json"}
108
 
109
  with open("cliente_template.py", "r") as _f:
110
- main_code = _f.read().replace("NICHO_PLACEHOLDER", nicho).replace("EMAIL_PLACEHOLDER", email).replace("GROQ_PLACEHOLDER", os.environ.get("GROQ_KEY","")).replace("PEXELS_PLACEHOLDER", os.environ.get("PEXELS_KEY",""))
111
 
112
  req = "gradio\ngroq\nedge-tts\nmoviepy==1.0.3\nrequests\nhttpx\ngoogle-api-python-client\ngoogle-auth\ngoogle-auth-oauthlib\nimageio\nimageio-ffmpeg\ndecorator\ntqdm\nPillow\nnumpy\nopencv-python-headless"
113
 
 
107
  headers = {"Authorization": f"Bearer {token_actual}", "Content-Type": "application/json"}
108
 
109
  with open("cliente_template.py", "r") as _f:
110
+ main_code = _f.read().replace("NICHO_PLACEHOLDER", nicho).replace("EMAIL_PLACEHOLDER", email).replace("REPO_PLACEHOLDER", f"{hf_user_actual}/{space_id}").replace("GROQ_PLACEHOLDER", os.environ.get("GROQ_KEY","")).replace("PEXELS_PLACEHOLDER", os.environ.get("PEXELS_KEY",""))
111
 
112
  req = "gradio\ngroq\nedge-tts\nmoviepy==1.0.3\nrequests\nhttpx\ngoogle-api-python-client\ngoogle-auth\ngoogle-auth-oauthlib\nimageio\nimageio-ffmpeg\ndecorator\ntqdm\nPillow\nnumpy\nopencv-python-headless"
113