06-sep: [fix] borrado NAS real (id plano + error por tarea), blqdev reconstruye lista, ayudas torrents

This commit is contained in:
juanjo
2026-09-06 16:32:49 +02:00
parent 9b4afd9f91
commit 2ac60433ae
2 changed files with 23 additions and 7 deletions

View File

@@ -600,7 +600,10 @@ def _mostrar_resultados(chat_id, message_id, tipo):
"🧲 Elige el título para ver sus torrents:",
teclado_resultados(titulos, "torrents"))
else:
_enviar_nuevo(chat_id, "Primero haz una <b>/busca</b> o usa <code>/torrents &lt;n&gt;</code>.", None)
_enviar_nuevo(chat_id, "Primero busca arriba con <b>🔎 Buscar</b>, "
"<b>🎬 Película</b>, <b>📺 Serie</b> o "
"<b>🆕 Novedades</b> y luego pulsa "
"<b>🧲 Torrents…</b>.", None)
return
torrents = _txt("ultimos_torrents", chat_id)
if torrents:
@@ -608,7 +611,8 @@ def _mostrar_resultados(chat_id, message_id, tipo):
f"⬇️ Elige torrent de «{torrents.get('titulo')}»:",
teclado_resultados(torrents.get("torrents", []), "bajar"))
else:
_enviar_nuevo(chat_id, "Primero consulta <code>/torrents &lt;n&gt;</code> de un título.", None)
_enviar_nuevo(chat_id, "Primero elige un título en <b>🧲 Torrents…</b> "
"y luego pulsa <b>⬇️ Bajar…</b>.", None)
def _ejecutar_parental(chat_id, message_id, accion, nombre):
@@ -688,6 +692,13 @@ def _ejecutar_accion(chat_id, message_id, partes):
_record_cat(chat_id, "parental")
lista = menu_dispositivos.get(chat_id) or []
numero = int(sub) if sub.isdigit() else 0
if not lista and numero:
try:
from asus_api_control import listar_dispositivos as _ld
lista = _ld()
menu_dispositivos[chat_id] = lista
except Exception:
lista = []
if 1 <= numero <= len(lista):
d = lista[numero - 1]
try:
@@ -702,6 +713,8 @@ def _ejecutar_accion(chat_id, message_id, partes):
"📺 <b>Bloquear dispositivo</b>\nPulsa el número para "
"bloquear/desbloquear:",
teclado_dispositivos(lista))
else:
_mostrar_dispositivos(chat_id, message_id)
return
if accion == "mesilla":
# sub: estado | nombre | nombre:accion

View File

@@ -248,24 +248,27 @@ def listar_tareas(session=None):
def borrar_tarea(tid, session=None):
"""Borra una tarea de Download Station por su id.
Devuelve (ok, detalle)."""
Devuelve (ok, detalle). OJO: la API responde success:true aunque falle:
el error real va por tarea (error 0 = borrada). Con version=3 el id
va como texto plano, no como array JSON (eso da error 544)."""
if not session:
session = login()
if not session:
return False, "No se pudo autenticar con Download Station."
try:
import json as _json
r = _api("/webapi/DownloadStation/task.cgi", {
"api": "SYNO.DownloadStation.Task",
"version": "3",
"method": "delete",
"id": _json.dumps([tid]),
"id": tid,
}, session=session)
except Exception as e:
return False, str(e)
if r.get("success"):
detalle = r.get("data") or []
if r.get("success") and detalle and all(
e.get("error", -1) == 0 for e in detalle):
return True, "ok"
return False, str(r.get("error"))
return False, str(detalle or r.get("error"))
if __name__ == "__main__":