commit a8dbcd3bcac2c7f550e4daeccd81c7497d68b3a2
parent e7bae78efb8b12ca0e9c503d9c54929458ef6867
Author: archiveanon <>
Date: Fri, 24 Apr 2026 09:47:27 +0000
Drop qbittorrentapi dependency
Diffstat:
2 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
@@ -10,9 +10,6 @@ dependencies = [
"microdot ~= 2.0.7",
"msgspec ~= 0.19.0",
- # for some reason the latest version does not play nice with Debian 12's qBittorrent builds...
- "qbittorrent-api >= 2022.7.33",
-
"stamina ~= 24.3.0",
"torf ~= 4.2.7",
]
diff --git a/src/autotako/job_render.py b/src/autotako/job_render.py
@@ -15,11 +15,10 @@ import gofile.api # type: ignore
import httpx
import microdot # type: ignore
import msgspec
-import qbittorrentapi # type: ignore
import stamina
import torf # type: ignore
-from .config import WebDavConfig, config_ctx
+from .config import QBittorrentConfig, WebDavConfig, config_ctx
from .database import database_ctx
app = microdot.Microdot()
@@ -305,6 +304,18 @@ async def do_webdav_upload(webdav: WebDavConfig, filepath: pathlib.Path, target:
await asyncio.sleep(10)
+async def get_qbittorrent_session(qbt_config: QBittorrentConfig) -> httpx.AsyncClient:
+ client = httpx.AsyncClient(
+ base_url=urllib.parse.urljoin(qbt_config.host, "api/v2/"), verify=False
+ )
+ r = await client.post(
+ "auth/login",
+ data={"username": qbt_config.username, "password": qbt_config.password},
+ )
+ r.raise_for_status()
+ return client
+
+
async def _process_job(jobid):
job = await get_moombox_job_by_id(jobid)
if not job:
@@ -361,26 +372,24 @@ async def _process_job(jobid):
if config.qbittorrent:
if config.qbittorrent.default_save_path:
save_path = config.qbittorrent.default_save_path
- qbt_client = qbittorrentapi.Client(
- host=config.qbittorrent.host,
- username=config.qbittorrent.username,
- password=config.qbittorrent.password,
- VERIFY_WEBUI_CERTIFICATE=False,
- RAISE_NOTIMPLEMENTEDERROR_FOR_UNIMPLEMENTED_API_ENDPOINTS=True,
- )
- task = asyncio.create_task(
- asyncio.to_thread(
- qbt_client.torrents_add,
- torrent_files=torrent_file,
- save_path=save_path,
- content_layout="NoSubfolder",
- # annoyingly, the API doesn't translate these kwargs
- # - is_paused for 4.5.2 (Debian 12, qbittorrent-api==2022.7.33)
- # - is_stopped for 5.1.0 (Debian 13, qbittorrent-api==2025.11.1)
- is_paused=config.qbittorrent.start_paused,
- is_stopped=config.qbittorrent.start_paused,
- )
- )
+ client = await get_qbittorrent_session(config.qbittorrent)
+ files = [
+ (
+ "torrents",
+ (
+ torrent_file.name,
+ torrent_file.open("rb"),
+ "application/x-bittorrent",
+ ),
+ ),
+ ]
+ data = {
+ "savepath": save_path,
+ "contentLayout": "NoSubfolder",
+ "stopped": "true" if config.qbittorrent.start_paused else "false",
+ "paused": "true" if config.qbittorrent.start_paused else "false",
+ }
+ task = asyncio.create_task(client.post("torrents/add", files=files, data=data))
background_tasks.add(task)
task.add_done_callback(background_tasks.discard)
else: