Spaces:
Running
Running
Tu Nombre commited on
Commit ·
ceea752
1
Parent(s): 05d246f
panel youtube y espera token
Browse files- cliente_template.py +13 -0
- main.py +2 -1
cliente_template.py
CHANGED
|
@@ -65,6 +65,9 @@ async def pipeline():
|
|
| 65 |
final = CompositeVideoClip([clip]+txts).set_audio(voz)
|
| 66 |
final.write_videofile("out.mp4", fps=20, codec="libx264", preset="ultrafast", logger=None)
|
| 67 |
log("Video renderizado")
|
|
|
|
|
|
|
|
|
|
| 68 |
STATUS = "Subiendo a YouTube..."
|
| 69 |
try:
|
| 70 |
import json, google.oauth2.credentials, googleapiclient.discovery, googleapiclient.http
|
|
@@ -112,6 +115,14 @@ threading.Thread(target=start, daemon=True).start()
|
|
| 112 |
CONTADOR_VIDEOS = 0
|
| 113 |
ULTIMO_VIDEO = "Ninguno aún"
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
def get_stats():
|
| 116 |
return f"📊 Videos publicados: {CONTADOR_VIDEOS} | 🎬 Último: {ULTIMO_VIDEO} | ⚡ Estado: {STATUS}"
|
| 117 |
|
|
@@ -133,6 +144,8 @@ textarea{background:#111!important;color:#D4AF37!important;font-family:monospace
|
|
| 133 |
gr.Textbox(label="", lines=20, every=4,
|
| 134 |
value=lambda: "\n".join(LOGS[-18:]) if LOGS else "Iniciando sistema...")
|
| 135 |
gr.Markdown("---")
|
|
|
|
|
|
|
| 136 |
gr.Markdown(f"### 💡 ¿Problemas? Escríbeme al WhatsApp: +34656691085")
|
| 137 |
|
| 138 |
demo.launch()
|
|
|
|
| 65 |
final = CompositeVideoClip([clip]+txts).set_audio(voz)
|
| 66 |
final.write_videofile("out.mp4", fps=20, codec="libx264", preset="ultrafast", logger=None)
|
| 67 |
log("Video renderizado")
|
| 68 |
+
STATUS = "Esperando conexión YouTube..."
|
| 69 |
+
while not os.path.exists("token.json"):
|
| 70 |
+
await asyncio.sleep(30)
|
| 71 |
STATUS = "Subiendo a YouTube..."
|
| 72 |
try:
|
| 73 |
import json, google.oauth2.credentials, googleapiclient.discovery, googleapiclient.http
|
|
|
|
| 115 |
CONTADOR_VIDEOS = 0
|
| 116 |
ULTIMO_VIDEO = "Ninguno aún"
|
| 117 |
|
| 118 |
+
def youtube_conectado():
|
| 119 |
+
return os.path.exists("token.json")
|
| 120 |
+
|
| 121 |
+
def get_yt_status():
|
| 122 |
+
if youtube_conectado():
|
| 123 |
+
return "✅ YouTube conectado — publicando automáticamente"
|
| 124 |
+
return "❌ YouTube NO conectado — conecta tu canal para publicar"
|
| 125 |
+
|
| 126 |
def get_stats():
|
| 127 |
return f"📊 Videos publicados: {CONTADOR_VIDEOS} | 🎬 Último: {ULTIMO_VIDEO} | ⚡ Estado: {STATUS}"
|
| 128 |
|
|
|
|
| 144 |
gr.Textbox(label="", lines=20, every=4,
|
| 145 |
value=lambda: "\n".join(LOGS[-18:]) if LOGS else "Iniciando sistema...")
|
| 146 |
gr.Markdown("---")
|
| 147 |
+
gr.Textbox(label="🎬 Estado YouTube", every=5, value=lambda: get_yt_status(), interactive=False)
|
| 148 |
+
gr.HTML(value='<div style="text-align:center;padding:16px"><a href="https://cristobal299-iaweb.hf.space/oauth-youtube?email={CLIENT_EMAIL}".format(CLIENT_EMAIL=CLIENT_EMAIL)" target="_blank" style="background:#ff0000;color:#fff;padding:14px 28px;border-radius:8px;text-decoration:none;font-weight:800;font-size:1.1rem">📺 CONECTAR MI CANAL DE YOUTUBE</a></div>')
|
| 149 |
gr.Markdown(f"### 💡 ¿Problemas? Escríbeme al WhatsApp: +34656691085")
|
| 150 |
|
| 151 |
demo.launch()
|
main.py
CHANGED
|
@@ -162,7 +162,8 @@ CMD [\"uvicorn\", \"main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"7860\"]""
|
|
| 162 |
"GROQ_KEY": os.environ.get("GROQ_KEY",""),
|
| 163 |
"PEXELS_KEY": os.environ.get("PEXELS_KEY",""),
|
| 164 |
"GOOGLE_CLIENT_ID": os.environ.get("GOOGLE_CLIENT_ID",""),
|
| 165 |
-
"GOOGLE_CLIENT_SECRET": os.environ.get("GOOGLE_CLIENT_SECRET","")
|
|
|
|
| 166 |
}
|
| 167 |
for key, val in secretos.items():
|
| 168 |
await client.post(
|
|
|
|
| 162 |
"GROQ_KEY": os.environ.get("GROQ_KEY",""),
|
| 163 |
"PEXELS_KEY": os.environ.get("PEXELS_KEY",""),
|
| 164 |
"GOOGLE_CLIENT_ID": os.environ.get("GOOGLE_CLIENT_ID",""),
|
| 165 |
+
"GOOGLE_CLIENT_SECRET": os.environ.get("GOOGLE_CLIENT_SECRET",""),
|
| 166 |
+
"CLIENT_EMAIL": email,
|
| 167 |
}
|
| 168 |
for key, val in secretos.items():
|
| 169 |
await client.post(
|