06-sep: [fix] borrado NAS real (id plano + error por tarea), blqdev reconstruye lista, ayudas torrents
This commit is contained in:
@@ -600,7 +600,10 @@ def _mostrar_resultados(chat_id, message_id, tipo):
|
|||||||
"🧲 Elige el título para ver sus torrents:",
|
"🧲 Elige el título para ver sus torrents:",
|
||||||
teclado_resultados(titulos, "torrents"))
|
teclado_resultados(titulos, "torrents"))
|
||||||
else:
|
else:
|
||||||
_enviar_nuevo(chat_id, "Primero haz una <b>/busca</b> o usa <code>/torrents <n></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
|
return
|
||||||
torrents = _txt("ultimos_torrents", chat_id)
|
torrents = _txt("ultimos_torrents", chat_id)
|
||||||
if torrents:
|
if torrents:
|
||||||
@@ -608,7 +611,8 @@ def _mostrar_resultados(chat_id, message_id, tipo):
|
|||||||
f"⬇️ Elige torrent de «{torrents.get('titulo')}»:",
|
f"⬇️ Elige torrent de «{torrents.get('titulo')}»:",
|
||||||
teclado_resultados(torrents.get("torrents", []), "bajar"))
|
teclado_resultados(torrents.get("torrents", []), "bajar"))
|
||||||
else:
|
else:
|
||||||
_enviar_nuevo(chat_id, "Primero consulta <code>/torrents <n></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):
|
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")
|
_record_cat(chat_id, "parental")
|
||||||
lista = menu_dispositivos.get(chat_id) or []
|
lista = menu_dispositivos.get(chat_id) or []
|
||||||
numero = int(sub) if sub.isdigit() else 0
|
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):
|
if 1 <= numero <= len(lista):
|
||||||
d = lista[numero - 1]
|
d = lista[numero - 1]
|
||||||
try:
|
try:
|
||||||
@@ -702,6 +713,8 @@ def _ejecutar_accion(chat_id, message_id, partes):
|
|||||||
"📺 <b>Bloquear dispositivo</b>\nPulsa el número para "
|
"📺 <b>Bloquear dispositivo</b>\nPulsa el número para "
|
||||||
"bloquear/desbloquear:",
|
"bloquear/desbloquear:",
|
||||||
teclado_dispositivos(lista))
|
teclado_dispositivos(lista))
|
||||||
|
else:
|
||||||
|
_mostrar_dispositivos(chat_id, message_id)
|
||||||
return
|
return
|
||||||
if accion == "mesilla":
|
if accion == "mesilla":
|
||||||
# sub: estado | nombre | nombre:accion
|
# sub: estado | nombre | nombre:accion
|
||||||
|
|||||||
@@ -248,24 +248,27 @@ def listar_tareas(session=None):
|
|||||||
|
|
||||||
def borrar_tarea(tid, session=None):
|
def borrar_tarea(tid, session=None):
|
||||||
"""Borra una tarea de Download Station por su id.
|
"""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:
|
if not session:
|
||||||
session = login()
|
session = login()
|
||||||
if not session:
|
if not session:
|
||||||
return False, "No se pudo autenticar con Download Station."
|
return False, "No se pudo autenticar con Download Station."
|
||||||
try:
|
try:
|
||||||
import json as _json
|
|
||||||
r = _api("/webapi/DownloadStation/task.cgi", {
|
r = _api("/webapi/DownloadStation/task.cgi", {
|
||||||
"api": "SYNO.DownloadStation.Task",
|
"api": "SYNO.DownloadStation.Task",
|
||||||
"version": "3",
|
"version": "3",
|
||||||
"method": "delete",
|
"method": "delete",
|
||||||
"id": _json.dumps([tid]),
|
"id": tid,
|
||||||
}, session=session)
|
}, session=session)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, str(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 True, "ok"
|
||||||
return False, str(r.get("error"))
|
return False, str(detalle or r.get("error"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user