Skip to content

Commit

Permalink
Fix sabnzbd delete history and some other minor bugs
Browse files Browse the repository at this point in the history
Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed May 17, 2024
1 parent ad9024d commit 429faf5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ quotes, even if it's `Int`, `Bool` or `List`.
- [READ THIS FOR MORE INFORMATION](https://sabnzbd.org/wiki/configuration/4.2/servers)

- **NOTE**: Enable port 8070 in your vps to access sabnzbd full web interface
- Open port 8070 in your vps to access web interface from any device.
- Open port 8070 in your vps to access web interface from any device. Use it like http://ip:8070/sabnzbd/.

**10. RSS**

Expand Down
2 changes: 1 addition & 1 deletion bot/helper/listeners/nzb_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

async def _remove_job(client, nzo_id, mid):
res1, _ = await gather(
client.delete_history(nzo_id, del_files=True), client.delete_category(f"{mid}")
client.delete_history(nzo_id, delete_files=True), client.delete_category(f"{mid}")
)
if not res1:
await client.delete_job(nzo_id, True)
Expand Down
11 changes: 5 additions & 6 deletions bot/helper/mirror_leech_utils/download_utils/nzb_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,16 @@ async def add_nzb(listener, path):

job_id = res["nzo_ids"][0]

await sleep(0.5)

downloads = await client.get_downloads(nzo_ids=job_id)
if not downloads["queue"]["slots"]:
await sleep(1)
history = await client.get_history(nzo_ids=job_id)
if history["history"]["slots"][0]["status"] == "Failed":
err = (
history["slots"][0]["fail_message"]
or "Link not added, unknown error!"
)
if err := history["history"]["slots"][0]["fail_message"]:
await gather(
listener.onDownloadError(err),
client.delete_history(job_id, del_files=True),
client.delete_history(job_id, delete_files=True),
)
return
name = history["history"]["slots"][0]["name"]
Expand Down
6 changes: 1 addition & 5 deletions bot/helper/mirror_leech_utils/status_utils/nzb_status.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from asyncio import gather
from time import time

from bot import LOGGER, get_sabnzb_client, nzb_jobs, nzb_listener_lock
from bot.helper.ext_utils.bot_utils import async_to_sync
Expand Down Expand Up @@ -33,7 +32,6 @@ def __init__(self, listener, gid, queued=False, status=None):
self.cstatus = status
self._gid = gid
self._info = None
self._start_time = time()

async def update(self):
self._info = await get_download(self.client, self._gid, self._info)
Expand All @@ -49,9 +47,7 @@ def processed_bytes(self):

def speed_raw(self):
try:
return (
int(float(self._info["mb"]) - float(self._info["mbleft"])) * 1048576
) / (time() - self._start_time)
return int(float(self._info["mb"]) * 1048576) / self.eta_raw()
except:
return 0

Expand Down
5 changes: 3 additions & 2 deletions sabnzbdapi/job_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,16 @@ async def retry_all(self):
return await self.call({"mode": "retry_all"})

async def delete_history(
self, nzo_ids: str | list[str], archive: int = 0, del_files: int = 0
self, nzo_ids: str | list[str], archive: int = 0, delete_files: int = 0
):
"""return {"status": True}"""
return await self.call(
{
"mode": "history",
"name": "delete",
"value": nzo_ids if isinstance(nzo_ids, str) else ",".join(nzo_ids),
"archive": archive,
"del_files": del_files,
"del_files": 1 if delete_files else 0,
}
)

Expand Down

0 comments on commit 429faf5

Please sign in to comment.