diff --git a/vigilancia/menu_idd.py b/vigilancia/menu_idd.py index 8d8eb8c..c65a642 100644 --- a/vigilancia/menu_idd.py +++ b/vigilancia/menu_idd.py @@ -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 /busca o usa /torrents <n>.", None) + _enviar_nuevo(chat_id, "Primero busca arriba con 🔎 Buscar, " + "🎬 Película, 📺 Serie o " + "🆕 Novedades y luego pulsa " + "🧲 Torrents….", 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 /torrents <n> de un título.", None) + _enviar_nuevo(chat_id, "Primero elige un título en 🧲 Torrents… " + "y luego pulsa ⬇️ Bajar….", 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): "📺 Bloquear dispositivo\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 diff --git a/vigilancia/nas_dl.py b/vigilancia/nas_dl.py index 0183936..cf96b7e 100644 --- a/vigilancia/nas_dl.py +++ b/vigilancia/nas_dl.py @@ -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__":