diff --git a/backend/app/clients/qbittorrent.py b/backend/app/clients/qbittorrent.py index 7204bf0..932c297 100644 --- a/backend/app/clients/qbittorrent.py +++ b/backend/app/clients/qbittorrent.py @@ -56,6 +56,9 @@ class QBittorrentClient(ApiClient): async def get_torrents_by_hashes(self, hashes: str) -> Optional[Any]: return await self._get("/api/v2/torrents/info", params={"hashes": hashes}) + async def get_torrents_by_category(self, category: str) -> Optional[Any]: + return await self._get("/api/v2/torrents/info", params={"category": category}) + async def get_app_version(self) -> Optional[Any]: return await self._get_text("/api/v2/app/version") diff --git a/backend/app/routers/requests.py b/backend/app/routers/requests.py index 82774a3..f3aa109 100644 --- a/backend/app/routers/requests.py +++ b/backend/app/routers/requests.py @@ -1591,7 +1591,7 @@ async def action_grab( if not qbit.configured(): raise HTTPException(status_code=400, detail="qBittorrent not configured") try: - await qbit.add_torrent_url(str(download_url)) + await qbit.add_torrent_url(str(download_url), category=f"magent-{request_id}") except httpx.HTTPStatusError as qbit_exc: raise HTTPException(status_code=502, detail=str(qbit_exc)) from qbit_exc await asyncio.to_thread( @@ -1625,7 +1625,7 @@ async def action_grab( if not qbit.configured(): raise HTTPException(status_code=400, detail="qBittorrent not configured") try: - await qbit.add_torrent_url(str(download_url)) + await qbit.add_torrent_url(str(download_url), category=f"magent-{request_id}") except httpx.HTTPStatusError as qbit_exc: raise HTTPException(status_code=502, detail=str(qbit_exc)) from qbit_exc await asyncio.to_thread( diff --git a/backend/app/services/snapshot.py b/backend/app/services/snapshot.py index 55c89b4..4c089b1 100644 --- a/backend/app/services/snapshot.py +++ b/backend/app/services/snapshot.py @@ -465,9 +465,14 @@ async def build_snapshot(request_id: str) -> Snapshot: try: download_ids = _download_ids(_queue_records(arr_queue)) torrent_list: List[Dict[str, Any]] = [] - if download_ids and qbittorrent.configured(): - torrents = await qbittorrent.get_torrents_by_hashes("|".join(download_ids)) - torrent_list = torrents if isinstance(torrents, list) else [] + if qbittorrent.configured(): + if download_ids: + torrents = await qbittorrent.get_torrents_by_hashes("|".join(download_ids)) + torrent_list = torrents if isinstance(torrents, list) else [] + else: + category = f"magent-{request_id}" + torrents = await qbittorrent.get_torrents_by_category(category) + torrent_list = torrents if isinstance(torrents, list) else [] summary = _summarize_qbit(torrent_list) qbit_state = summary.get("state") qbit_message = summary.get("message") diff --git a/frontend/app/ui/HeaderActions.tsx b/frontend/app/ui/HeaderActions.tsx index 2b915c7..a498150 100644 --- a/frontend/app/ui/HeaderActions.tsx +++ b/frontend/app/ui/HeaderActions.tsx @@ -40,19 +40,19 @@ export default function HeaderActions() { } } + if (!signedIn) { + return null + } + return (