02-ago: [proyecto] vigilancia - YouTube en la tele: youtube <URL> reproduce video y apaga al terminar. Comando en el bot.
This commit is contained in:
@@ -94,6 +94,15 @@ def mandar_tv(mensaje, simple):
|
||||
return False
|
||||
|
||||
|
||||
def mandar_youtube(url):
|
||||
try:
|
||||
r = requests.get(f"http://127.0.0.1:8600/tv/youtube?url={url}", timeout=10)
|
||||
return r.status_code == 200
|
||||
except Exception as e:
|
||||
log(f"youtube error: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def procesar(texto, chat_id):
|
||||
t = texto.lower().strip()
|
||||
log(f"RECIBIDO chat={chat_id} texto={texto!r}")
|
||||
@@ -119,7 +128,7 @@ def procesar(texto, chat_id):
|
||||
ok = mandar_tv(msj, simple=False)
|
||||
enviar("🚨 Alarma lanzada en la tele ✅" if ok
|
||||
else "❌ No se pudo lanzar la alarma", chat_id)
|
||||
elif t in ("panorama", "/panorama"):
|
||||
elif t.startswith("panorama") or t.startswith("/panorama"):
|
||||
enviar("📷 Capturando snapshots de las cámaras...", chat_id)
|
||||
try:
|
||||
import subprocess as sp
|
||||
@@ -128,12 +137,20 @@ def procesar(texto, chat_id):
|
||||
log(f"panorama: {r.stdout.strip()[-200:]}")
|
||||
except Exception as e:
|
||||
log(f"panorama error: {e}")
|
||||
elif t.startswith("youtube ") or t.startswith("/youtube "):
|
||||
url = texto.split(" ", 1)[1].strip()
|
||||
if not url:
|
||||
enviar("Uso: <b>youtube <URL></b>", chat_id)
|
||||
else:
|
||||
ok = mandar_youtube(url)
|
||||
enviar("🎬 YouTube lanzado en la TV ✅" if ok else "❌ No se pudo lanzar YouTube", chat_id)
|
||||
elif t in ("ayuda", "/ayuda", "help", "/help"):
|
||||
enviar("Comandos:\n"
|
||||
"<b>estado</b> — estado de la Pi\n"
|
||||
"<b>temperatura</b> — temperatura\n"
|
||||
"<b>tv <mensaje></b> — mensaje rápido a la tele\n"
|
||||
"<b>alarma <mensaje></b> — secuencia completa (sirena x3)\n"
|
||||
"<b>youtube <URL></b> — reproduce YouTube y apaga al terminar\n"
|
||||
"<b>panorama</b> — fotos de las cámaras",
|
||||
chat_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user