Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5829623a9e | ||
|
|
c2ccb0d4bb | ||
|
|
f9eb633e19 | ||
|
|
ce82a405c5 | ||
|
|
22a1fc5522 | ||
|
|
581934f7b5 | ||
|
|
2ff670a9ae |
@@ -3,6 +3,9 @@ IMPORTARR_SAB_URL=http://sabnzbd:8080
|
|||||||
# IMPORTARR_SAB_API_KEY=change-me
|
# IMPORTARR_SAB_API_KEY=change-me
|
||||||
# IMPORTARR_SAB_API_KEY_FILE=/etc/importarr/sab-api-key
|
# IMPORTARR_SAB_API_KEY_FILE=/etc/importarr/sab-api-key
|
||||||
IMPORTARR_SAB_CATEGORY=manual
|
IMPORTARR_SAB_CATEGORY=manual
|
||||||
|
# SAB may report storage paths from inside its container; set this when that
|
||||||
|
# differs from the local host path Importarr scans in IMPORTARR_DOWNLOAD_ROOT.
|
||||||
|
# IMPORTARR_SAB_STORAGE_ROOT=/data/downloads/manual
|
||||||
IMPORTARR_DOWNLOAD_ROOT=/data/downloads/manual
|
IMPORTARR_DOWNLOAD_ROOT=/data/downloads/manual
|
||||||
IMPORTARR_MOVIES_ROOT=/data/movies
|
IMPORTARR_MOVIES_ROOT=/data/movies
|
||||||
IMPORTARR_TV_ROOT=/data/tv
|
IMPORTARR_TV_ROOT=/data/tv
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class Settings(BaseModel):
|
|||||||
sab_url: str = "http://sabnzbd:8080"
|
sab_url: str = "http://sabnzbd:8080"
|
||||||
sab_api_key: str | None = None
|
sab_api_key: str | None = None
|
||||||
sab_category: str = "manual"
|
sab_category: str = "manual"
|
||||||
|
sab_storage_root: Path | None = None
|
||||||
download_root: Path = Path("/data/downloads/manual")
|
download_root: Path = Path("/data/downloads/manual")
|
||||||
movies_root: Path = Path("/data/movies")
|
movies_root: Path = Path("/data/movies")
|
||||||
tv_root: Path = Path("/data/tv")
|
tv_root: Path = Path("/data/tv")
|
||||||
@@ -30,6 +31,7 @@ class Settings(BaseModel):
|
|||||||
sab_url=os.getenv("IMPORTARR_SAB_URL", cls.model_fields["sab_url"].default),
|
sab_url=os.getenv("IMPORTARR_SAB_URL", cls.model_fields["sab_url"].default),
|
||||||
sab_api_key=_env_secret("IMPORTARR_SAB_API_KEY"),
|
sab_api_key=_env_secret("IMPORTARR_SAB_API_KEY"),
|
||||||
sab_category=os.getenv("IMPORTARR_SAB_CATEGORY", "manual"),
|
sab_category=os.getenv("IMPORTARR_SAB_CATEGORY", "manual"),
|
||||||
|
sab_storage_root=Path(os.getenv("IMPORTARR_SAB_STORAGE_ROOT")) if os.getenv("IMPORTARR_SAB_STORAGE_ROOT") else None,
|
||||||
download_root=Path(os.getenv("IMPORTARR_DOWNLOAD_ROOT", "/data/downloads/manual")),
|
download_root=Path(os.getenv("IMPORTARR_DOWNLOAD_ROOT", "/data/downloads/manual")),
|
||||||
movies_root=Path(os.getenv("IMPORTARR_MOVIES_ROOT", "/data/movies")),
|
movies_root=Path(os.getenv("IMPORTARR_MOVIES_ROOT", "/data/movies")),
|
||||||
tv_root=Path(os.getenv("IMPORTARR_TV_ROOT", "/data/tv")),
|
tv_root=Path(os.getenv("IMPORTARR_TV_ROOT", "/data/tv")),
|
||||||
|
|||||||
+70
-5
@@ -4,6 +4,7 @@ from pathlib import Path
|
|||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
import httpx
|
||||||
from fastapi import Depends, FastAPI, Header, HTTPException, Request
|
from fastapi import Depends, FastAPI, Header, HTTPException, Request
|
||||||
from fastapi.responses import HTMLResponse
|
from fastapi.responses import HTMLResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
@@ -50,6 +51,12 @@ class AppSettingsUpdate(BaseModel):
|
|||||||
sonarr_api_key: str | None = None
|
sonarr_api_key: str | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionTestRequest(BaseModel):
|
||||||
|
service: str
|
||||||
|
url: str
|
||||||
|
api_key: str | None = None
|
||||||
|
|
||||||
|
|
||||||
def load_ui_settings() -> None:
|
def load_ui_settings() -> None:
|
||||||
for key in ("sab_url", "sab_api_key", "radarr_url", "radarr_api_key", "sonarr_url", "sonarr_api_key"):
|
for key in ("sab_url", "sab_api_key", "radarr_url", "radarr_api_key", "sonarr_url", "sonarr_api_key"):
|
||||||
stored = state.get_app_state(key)
|
stored = state.get_app_state(key)
|
||||||
@@ -136,6 +143,33 @@ def update_ui_settings(payload: AppSettingsUpdate, _: None = Depends(require_wri
|
|||||||
return get_ui_settings()
|
return get_ui_settings()
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/api/settings/test-connection")
|
||||||
|
async def test_connection(payload: ConnectionTestRequest, _: None = Depends(require_write_auth)) -> dict[str, object]:
|
||||||
|
service = payload.service.strip().lower()
|
||||||
|
url = payload.url.strip().rstrip("/")
|
||||||
|
api_key = (payload.api_key or "").strip() or None
|
||||||
|
if service not in {"sabnzbd", "radarr", "sonarr"}:
|
||||||
|
raise HTTPException(status_code=400, detail="service must be sabnzbd, radarr, or sonarr")
|
||||||
|
if not url:
|
||||||
|
raise HTTPException(status_code=400, detail="URL is required")
|
||||||
|
if api_key is None:
|
||||||
|
api_key = getattr(settings, f"{service if service != 'sabnzbd' else 'sab'}_api_key")
|
||||||
|
try:
|
||||||
|
if service == "sabnzbd":
|
||||||
|
data = await SabnzbdClient(url, api_key).queue()
|
||||||
|
return {"ok": True, "service": service, "message": f"Connected to SABnzbd; {len(data.get('queue', {}).get('slots', []))} queued jobs visible."}
|
||||||
|
headers = {"X-Api-Key": api_key} if api_key else {}
|
||||||
|
async with httpx.AsyncClient(timeout=15) as client:
|
||||||
|
response = await client.get(f"{url}/api/v3/system/status", headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
data = response.json()
|
||||||
|
name = str(data.get("appName") or service.title())
|
||||||
|
version = str(data.get("version") or "unknown version")
|
||||||
|
return {"ok": True, "service": service, "message": f"Connected to {name} {version}."}
|
||||||
|
except Exception as exc:
|
||||||
|
return {"ok": False, "service": service, "message": f"Connection failed: {exc.__class__.__name__}"}
|
||||||
|
|
||||||
|
|
||||||
def control_status() -> dict[str, object]:
|
def control_status() -> dict[str, object]:
|
||||||
mode = state.get_app_state("queue_mode", "running") or "running"
|
mode = state.get_app_state("queue_mode", "running") or "running"
|
||||||
current = state.get_app_state("current_job")
|
current = state.get_app_state("current_job")
|
||||||
@@ -241,6 +275,10 @@ def queue_item_action(item_id: int, payload: QueueItemActionRequest, _: None = D
|
|||||||
if payload.action == "retry":
|
if payload.action == "retry":
|
||||||
retry_state = "manual_batch" if item["source_type"] == "manual" else "ready"
|
retry_state = "manual_batch" if item["source_type"] == "manual" else "ready"
|
||||||
state.mark_queue_item(item["source_type"], item["source_id"], retry_state, "retry requested")
|
state.mark_queue_item(item["source_type"], item["source_id"], retry_state, "retry requested")
|
||||||
|
elif payload.action == "run-now":
|
||||||
|
imported = _import_queue_item(item, Importer(settings.movies_root, settings.tv_root))
|
||||||
|
updated = state.get_queue_item(item_id)
|
||||||
|
return {"status": "imported" if imported else "updated", "imported": imported, "item": serialize_queue_item(updated or item)}
|
||||||
elif payload.action == "ignore":
|
elif payload.action == "ignore":
|
||||||
state.mark_queue_item(item["source_type"], item["source_id"], "skipped", "ignored by user")
|
state.mark_queue_item(item["source_type"], item["source_id"], "skipped", "ignored by user")
|
||||||
elif payload.action == "remove":
|
elif payload.action == "remove":
|
||||||
@@ -275,16 +313,17 @@ async def sync_queue() -> None:
|
|||||||
state.upsert_queue_item(source_type="system", source_id="sab-sync", name="SABnzbd", state="failed", reason=exc.__class__.__name__)
|
state.upsert_queue_item(source_type="system", source_id="sab-sync", name="SABnzbd", state="failed", reason=exc.__class__.__name__)
|
||||||
return
|
return
|
||||||
slots = data.get("history", {}).get("slots", [])
|
slots = data.get("history", {}).get("slots", [])
|
||||||
|
state.delete_queue_items_by_state("sab", "ignored")
|
||||||
for item in slots:
|
for item in slots:
|
||||||
readiness = classify_history_item(item, active, settings.sab_category, settings.download_root)
|
readiness = classify_history_item(item, active, settings.sab_category, settings.download_root, sab_storage_root=settings.sab_storage_root)
|
||||||
job_id = str(item.get("nzo_id") or item.get("nzoid") or item.get("name") or "")
|
job_id = str(item.get("nzo_id") or item.get("nzoid") or item.get("name") or "")
|
||||||
if not job_id:
|
if not job_id:
|
||||||
continue
|
continue
|
||||||
if readiness.ready and readiness.storage:
|
if readiness.ready and readiness.storage:
|
||||||
for video in scan_videos(readiness.storage):
|
for video in scan_videos(readiness.storage):
|
||||||
state.upsert_queue_item(source_type="sab", source_id=str(video.path), source_path=video.path, name=video.path.name, state="ready", reason=readiness.reason, relative_path=str(video.relative_path), size=video.size, job_id=job_id)
|
state.upsert_queue_item(source_type="sab", source_id=str(video.path), source_path=video.path, name=video.path.name, state="ready", reason=readiness.reason, relative_path=str(video.relative_path), size=video.size, job_id=job_id, sab_category=str(item.get("category") or item.get("cat") or ""))
|
||||||
else:
|
else:
|
||||||
state.upsert_queue_item(source_type="sab", source_id=job_id, source_path=readiness.storage, name=str(item.get("name") or job_id), state=readiness.state, reason=readiness.reason, job_id=job_id)
|
state.upsert_queue_item(source_type="sab", source_id=job_id, source_path=readiness.storage, name=str(item.get("name") or job_id), state=readiness.state, reason=readiness.reason, job_id=job_id, sab_category=str(item.get("category") or item.get("cat") or ""))
|
||||||
|
|
||||||
|
|
||||||
def queue_jobs() -> list[dict[str, object]]:
|
def queue_jobs() -> list[dict[str, object]]:
|
||||||
@@ -311,7 +350,7 @@ def serialize_queue_item(item: dict[str, object]) -> dict[str, object]:
|
|||||||
"updated_at": item["updated_at"],
|
"updated_at": item["updated_at"],
|
||||||
"completed_at": item["completed_at"],
|
"completed_at": item["completed_at"],
|
||||||
"sab_status": state_name if source_type == "sab" else None,
|
"sab_status": state_name if source_type == "sab" else None,
|
||||||
"sab_category": settings.sab_category if source_type == "sab" else None,
|
"sab_category": item.get("sab_category") if source_type == "sab" else None,
|
||||||
"can_run_now": state_name in {"ready", "manual_batch", "failed"},
|
"can_run_now": state_name in {"ready", "manual_batch", "failed"},
|
||||||
"can_retry": state_name in {"failed", "skipped"},
|
"can_retry": state_name in {"failed", "skipped"},
|
||||||
"can_ignore": state_name not in {"imported", "skipped"},
|
"can_ignore": state_name not in {"imported", "skipped"},
|
||||||
@@ -387,7 +426,7 @@ async def _import_ready_sab_jobs(importer: Importer, force: bool = False) -> int
|
|||||||
for item in data.get("history", {}).get("slots", []):
|
for item in data.get("history", {}).get("slots", []):
|
||||||
if consume_cancel_request():
|
if consume_cancel_request():
|
||||||
break
|
break
|
||||||
readiness = classify_history_item(item, active, settings.sab_category, settings.download_root, force_status=force)
|
readiness = classify_history_item(item, active, settings.sab_category, settings.download_root, force_status=force, sab_storage_root=settings.sab_storage_root)
|
||||||
if readiness.storage is None or (not readiness.ready and not force):
|
if readiness.storage is None or (not readiness.ready and not force):
|
||||||
continue
|
continue
|
||||||
for video in scan_videos(readiness.storage):
|
for video in scan_videos(readiness.storage):
|
||||||
@@ -411,6 +450,32 @@ async def _import_ready_sab_jobs(importer: Importer, force: bool = False) -> int
|
|||||||
return imported
|
return imported
|
||||||
|
|
||||||
|
|
||||||
|
def _import_queue_item(item: dict[str, object], importer: Importer) -> int:
|
||||||
|
if item["source_type"] not in {"sab", "manual"} or item["state"] not in {"ready", "manual_batch", "failed"}:
|
||||||
|
return 0
|
||||||
|
source_path = item.get("source_path")
|
||||||
|
if not source_path:
|
||||||
|
state.mark_queue_item(str(item["source_type"]), str(item["source_id"]), "failed", "missing source path")
|
||||||
|
return 0
|
||||||
|
source = Path(str(source_path))
|
||||||
|
set_current_job(str(source))
|
||||||
|
try:
|
||||||
|
result = importer.import_file(source, should_cancel=consume_cancel_request)
|
||||||
|
state.add_history(result.source, result.target, "imported", result.bytes)
|
||||||
|
state.mark_queue_item(str(item["source_type"]), str(item["source_id"]), "imported")
|
||||||
|
return 1
|
||||||
|
except ImportCancelled:
|
||||||
|
state.add_history(source, source, "cancelled", 0, "cancelled")
|
||||||
|
state.mark_queue_item(str(item["source_type"]), str(item["source_id"]), "skipped", "cancelled")
|
||||||
|
return 0
|
||||||
|
except Exception as exc:
|
||||||
|
state.add_history(source, source, "failed", 0, exc.__class__.__name__)
|
||||||
|
state.mark_queue_item(str(item["source_type"]), str(item["source_id"]), "failed", exc.__class__.__name__)
|
||||||
|
return 0
|
||||||
|
finally:
|
||||||
|
set_current_job(None)
|
||||||
|
|
||||||
|
|
||||||
def _import_manual_batches(importer: Importer) -> int:
|
def _import_manual_batches(importer: Importer) -> int:
|
||||||
if queue_accepting_new_jobs():
|
if queue_accepting_new_jobs():
|
||||||
sync_manual_queue()
|
sync_manual_queue()
|
||||||
|
|||||||
+21
-9
@@ -26,25 +26,37 @@ def has_transient_part(path: Path) -> bool:
|
|||||||
return any(part in TRANSIENT_PARTS or any(token in part for token in TRANSIENT_PARTS) for part in path.parts)
|
return any(part in TRANSIENT_PARTS or any(token in part for token in TRANSIENT_PARTS) for part in path.parts)
|
||||||
|
|
||||||
|
|
||||||
def classify_history_item(item: dict[str, Any], active_nzo_ids: set[str], category: str, download_root: Path, force_status: bool = False) -> Readiness:
|
def classify_history_item(item: dict[str, Any], active_nzo_ids: set[str], category: str, download_root: Path, force_status: bool = False, sab_storage_root: Path | None = None) -> Readiness:
|
||||||
nzo_id = str(item.get("nzo_id") or item.get("nzoid") or "")
|
nzo_id = str(item.get("nzo_id") or item.get("nzoid") or "")
|
||||||
if not force_status and nzo_id and nzo_id in active_nzo_ids:
|
if not force_status and nzo_id and nzo_id in active_nzo_ids:
|
||||||
return Readiness("processing", "SAB job is still present in queue")
|
return Readiness("processing", "SAB job is still present in queue")
|
||||||
if str(item.get("category") or "") != category:
|
item_category = str(item.get("category") or item.get("cat") or "")
|
||||||
return Readiness("ignored", "SAB category is not owned by Importarr")
|
|
||||||
status = str(item.get("status") or "")
|
status = str(item.get("status") or "")
|
||||||
|
storage_value = str(item.get("storage") or "")
|
||||||
|
storage = Path(storage_value).resolve() if storage_value else None
|
||||||
|
root = download_root.resolve()
|
||||||
|
sab_root = (sab_storage_root or download_root).resolve()
|
||||||
|
storage_in_local_root = bool(storage and (storage == root or root in storage.parents))
|
||||||
|
storage_in_sab_root = bool(storage and (storage == sab_root or sab_root in storage.parents))
|
||||||
|
storage_in_root = storage_in_local_root or storage_in_sab_root
|
||||||
|
if item_category != category and not storage_in_root:
|
||||||
|
return Readiness("ignored", "SAB category/storage is not owned by Importarr", storage)
|
||||||
if not force_status and status == "Failed":
|
if not force_status and status == "Failed":
|
||||||
return Readiness("failed", "SAB history reports failure")
|
return Readiness("failed", "SAB history reports failure")
|
||||||
if not force_status and (status in NOT_READY_STATUSES or status != "Completed"):
|
if not force_status and (status in NOT_READY_STATUSES or status != "Completed"):
|
||||||
return Readiness("processing", f"SAB status is {status or 'unknown'}")
|
return Readiness("processing", f"SAB status is {status or 'unknown'}")
|
||||||
storage_value = str(item.get("storage") or "")
|
if storage is None:
|
||||||
if not storage_value:
|
|
||||||
return Readiness("unknown", "SAB completed item has no final storage")
|
return Readiness("unknown", "SAB completed item has no final storage")
|
||||||
storage = Path(storage_value).resolve()
|
if not storage_in_root:
|
||||||
root = download_root.resolve()
|
|
||||||
if storage != root and root not in storage.parents:
|
|
||||||
return Readiness("ignored", "SAB storage is outside configured download root", storage)
|
return Readiness("ignored", "SAB storage is outside configured download root", storage)
|
||||||
|
if storage_in_sab_root and not storage_in_local_root:
|
||||||
|
storage = root / storage.relative_to(sab_root)
|
||||||
if has_transient_part(storage):
|
if has_transient_part(storage):
|
||||||
return Readiness("processing", "SAB storage path contains transient unpack/admin marker", storage)
|
return Readiness("processing", "SAB storage path contains transient unpack/admin marker", storage)
|
||||||
reason = "forced despite SAB status" if force_status and status != "Completed" else "SAB completed in owned category with final storage"
|
if force_status and status != "Completed":
|
||||||
|
reason = "forced despite SAB status"
|
||||||
|
elif item_category != category:
|
||||||
|
reason = "SAB completed inside Importarr download root"
|
||||||
|
else:
|
||||||
|
reason = "SAB completed in owned category with final storage"
|
||||||
return Readiness("ready", reason, storage)
|
return Readiness("ready", reason, storage)
|
||||||
|
|||||||
+17
-3
@@ -46,6 +46,7 @@ class State:
|
|||||||
size integer not null default 0,
|
size integer not null default 0,
|
||||||
batch_id integer,
|
batch_id integer,
|
||||||
job_id text,
|
job_id text,
|
||||||
|
sab_category text,
|
||||||
first_seen_at text not null default current_timestamp,
|
first_seen_at text not null default current_timestamp,
|
||||||
updated_at text not null default current_timestamp,
|
updated_at text not null default current_timestamp,
|
||||||
completed_at text,
|
completed_at text,
|
||||||
@@ -53,6 +54,9 @@ class State:
|
|||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
columns = {row["name"] for row in self.conn.execute("pragma table_info(import_queue_items)")}
|
||||||
|
if "sab_category" not in columns:
|
||||||
|
self.conn.execute("alter table import_queue_items add column sab_category text")
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
def get_app_state(self, key: str, default: str | None = None) -> str | None:
|
def get_app_state(self, key: str, default: str | None = None) -> str | None:
|
||||||
@@ -111,11 +115,12 @@ class State:
|
|||||||
size: int = 0,
|
size: int = 0,
|
||||||
batch_id: int | None = None,
|
batch_id: int | None = None,
|
||||||
job_id: str | None = None,
|
job_id: str | None = None,
|
||||||
|
sab_category: str | None = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
self.conn.execute(
|
self.conn.execute(
|
||||||
"""
|
"""
|
||||||
insert into import_queue_items(source_type, source_id, source_path, name, state, reason, relative_path, size, batch_id, job_id)
|
insert into import_queue_items(source_type, source_id, source_path, name, state, reason, relative_path, size, batch_id, job_id, sab_category)
|
||||||
values (?,?,?,?,?,?,?,?,?,?)
|
values (?,?,?,?,?,?,?,?,?,?,?)
|
||||||
on conflict(source_type, source_id) do update set
|
on conflict(source_type, source_id) do update set
|
||||||
source_path=excluded.source_path,
|
source_path=excluded.source_path,
|
||||||
name=excluded.name,
|
name=excluded.name,
|
||||||
@@ -125,10 +130,11 @@ class State:
|
|||||||
size=excluded.size,
|
size=excluded.size,
|
||||||
batch_id=excluded.batch_id,
|
batch_id=excluded.batch_id,
|
||||||
job_id=excluded.job_id,
|
job_id=excluded.job_id,
|
||||||
|
sab_category=excluded.sab_category,
|
||||||
updated_at=current_timestamp,
|
updated_at=current_timestamp,
|
||||||
completed_at=case when excluded.state in ('imported','failed','skipped') then current_timestamp else null end
|
completed_at=case when excluded.state in ('imported','failed','skipped') then current_timestamp else null end
|
||||||
""",
|
""",
|
||||||
(source_type, source_id, str(source_path) if source_path else None, name, state, reason, relative_path, size, batch_id, job_id),
|
(source_type, source_id, str(source_path) if source_path else None, name, state, reason, relative_path, size, batch_id, job_id, sab_category),
|
||||||
)
|
)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
row = self.conn.execute("select * from import_queue_items where source_type = ? and source_id = ?", (source_type, source_id)).fetchone()
|
row = self.conn.execute("select * from import_queue_items where source_type = ? and source_id = ?", (source_type, source_id)).fetchone()
|
||||||
@@ -146,6 +152,14 @@ class State:
|
|||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
return cursor.rowcount > 0
|
return cursor.rowcount > 0
|
||||||
|
|
||||||
|
def delete_queue_items_by_state(self, source_type: str, state: str, reason: str | None = None) -> int:
|
||||||
|
if reason is None:
|
||||||
|
cursor = self.conn.execute("delete from import_queue_items where source_type = ? and state = ?", (source_type, state))
|
||||||
|
else:
|
||||||
|
cursor = self.conn.execute("delete from import_queue_items where source_type = ? and state = ? and reason = ?", (source_type, state, reason))
|
||||||
|
self.conn.commit()
|
||||||
|
return cursor.rowcount
|
||||||
|
|
||||||
def get_queue_item(self, item_id: int) -> dict[str, Any] | None:
|
def get_queue_item(self, item_id: int) -> dict[str, Any] | None:
|
||||||
row = self.conn.execute("select * from import_queue_items where id = ?", (item_id,)).fetchone()
|
row = self.conn.execute("select * from import_queue_items where id = ?", (item_id,)).fetchone()
|
||||||
return dict(row) if row else None
|
return dict(row) if row else None
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
body{font-family:system-ui,sans-serif;margin:0;background:#111827;color:#e5e7eb}header,main{max-width:1100px;margin:auto;padding:1rem}.topbar{display:flex;justify-content:space-between;gap:1rem;align-items:center;background:#0f172a}.build{text-align:right}.build strong{font-size:1.2rem}.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));gap:1rem}.cards article,.panel{background:#1f2937;border-radius:.75rem;padding:1rem;margin-top:1rem}strong{display:block;font-size:2rem}span,small,dd{color:#9ca3af}table{width:100%;border-collapse:collapse;background:#1f2937;margin-top:1rem}th,td{padding:.6rem;border-bottom:1px solid #374151;text-align:left;vertical-align:top}input,button{padding:.6rem;border-radius:.4rem;border:1px solid #374151}button{background:#38bdf8;color:#082f49;font-weight:700;cursor:pointer}.danger{background:#f87171;color:#450a0a}.warn{background:#fbbf24;color:#451a03}.controls,.row-actions{display:flex;gap:.5rem;flex-wrap:wrap}.inline-form{display:flex;gap:.5rem;flex-wrap:wrap}.inline-form input[name=path]{min-width:min(100%,28rem);flex:1}.info{display:grid;grid-template-columns:10rem 1fr;gap:.4rem 1rem}.info dt{font-weight:700}.info dd{margin:0;overflow-wrap:anywhere}.state{background:#0f172a;border:1px solid #374151;border-radius:999px;padding:.15rem .5rem;display:inline-block}.section-title{display:flex;align-items:center;justify-content:space-between;gap:1rem}.job-group{margin-top:1.25rem}.job-group h3{display:flex;gap:.5rem;align-items:center}.job-group h3 span{font-size:.9rem;border:1px solid #374151;border-radius:999px;padding:.1rem .45rem}.file-name{font-size:1rem}.row-actions button{padding:.35rem .5rem}td small{display:block;overflow-wrap:anywhere}dialog{background:#1f2937;color:#e5e7eb;border:1px solid #374151;border-radius:.75rem;max-width:min(42rem,90vw)}dialog::backdrop{background:#0009}fieldset{border:1px solid #374151;border-radius:.5rem;margin:1rem 0;padding:1rem}label{display:grid;gap:.35rem;margin:.75rem 0}.hint{color:#9ca3af}
|
body{font-family:system-ui,sans-serif;margin:0;background:#111827;color:#e5e7eb}header,main{max-width:1100px;margin:auto;padding:1rem}.topbar{display:flex;justify-content:space-between;gap:1rem;align-items:center;background:#0f172a}.build{text-align:right}.build strong{font-size:1.2rem}.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));gap:1rem}.cards article,.panel{background:#1f2937;border-radius:.75rem;padding:1rem;margin-top:1rem}strong{display:block;font-size:2rem}span,small,dd{color:#9ca3af}table{width:100%;border-collapse:collapse;background:#1f2937;margin-top:1rem}th,td{padding:.6rem;border-bottom:1px solid #374151;text-align:left;vertical-align:top}input,button{padding:.6rem;border-radius:.4rem;border:1px solid #374151}button{background:#38bdf8;color:#082f49;font-weight:700;cursor:pointer}.danger{background:#f87171;color:#450a0a}.warn{background:#fbbf24;color:#451a03}.controls,.row-actions{display:flex;gap:.5rem;flex-wrap:wrap}.inline-form{display:flex;gap:.5rem;flex-wrap:wrap}.inline-form input[name=path]{min-width:min(100%,28rem);flex:1}.info{display:grid;grid-template-columns:10rem 1fr;gap:.4rem 1rem}.info dt{font-weight:700}.info dd{margin:0;overflow-wrap:anywhere}.state{background:#0f172a;border:1px solid #374151;border-radius:999px;padding:.15rem .5rem;display:inline-block}.section-title{display:flex;align-items:center;justify-content:space-between;gap:1rem}.job-group{margin-top:1.25rem}.job-group h3{display:flex;gap:.5rem;align-items:center}.job-group h3 span{font-size:.9rem;border:1px solid #374151;border-radius:999px;padding:.1rem .45rem}.file-name{font-size:1rem}.row-actions button{padding:.35rem .5rem}td small{display:block;overflow-wrap:anywhere}dialog{background:#1f2937;color:#e5e7eb;border:1px solid #374151;border-radius:.75rem;max-width:min(42rem,90vw)}dialog::backdrop{background:#0009}fieldset{border:1px solid #374151;border-radius:.5rem;margin:1rem 0;padding:1rem}label{display:grid;gap:.35rem;margin:.75rem 0}.hint{color:#9ca3af}output{display:block;margin-top:.5rem;color:#9ca3af}.success{color:#86efac}.error{color:#fca5a5}
|
||||||
|
|||||||
@@ -74,16 +74,19 @@
|
|||||||
<legend>SABnzbd</legend>
|
<legend>SABnzbd</legend>
|
||||||
<label>SAB URL <input name="sab_url" type="url" value="{{ status.sab_url }}" placeholder="http://sabnzbd:8080" required></label>
|
<label>SAB URL <input name="sab_url" type="url" value="{{ status.sab_url }}" placeholder="http://sabnzbd:8080" required></label>
|
||||||
<label>API token <input name="sab_api_key" type="password" placeholder="{% if status.sab_api_key_configured %}Configured; enter a new token to replace{% else %}SAB API token{% endif %}" autocomplete="off"></label>
|
<label>API token <input name="sab_api_key" type="password" placeholder="{% if status.sab_api_key_configured %}Configured; enter a new token to replace{% else %}SAB API token{% endif %}" autocomplete="off"></label>
|
||||||
|
<button type="button" data-test-connection="sabnzbd">Test SABnzbd connection</button><output id="sabnzbd-test-result"></output>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Radarr</legend>
|
<legend>Radarr</legend>
|
||||||
<label>Radarr URL <input name="radarr_url" type="url" value="{{ status.radarr_url }}" placeholder="http://radarr:7878"></label>
|
<label>Radarr URL <input name="radarr_url" type="url" value="{{ status.radarr_url }}" placeholder="http://radarr:7878"></label>
|
||||||
<label>API token <input name="radarr_api_key" type="password" placeholder="{% if status.radarr_api_key_configured %}Configured; enter a new token to replace{% else %}Radarr API token{% endif %}" autocomplete="off"></label>
|
<label>API token <input name="radarr_api_key" type="password" placeholder="{% if status.radarr_api_key_configured %}Configured; enter a new token to replace{% else %}Radarr API token{% endif %}" autocomplete="off"></label>
|
||||||
|
<button type="button" data-test-connection="radarr">Test Radarr connection</button><output id="radarr-test-result"></output>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Sonarr</legend>
|
<legend>Sonarr</legend>
|
||||||
<label>Sonarr URL <input name="sonarr_url" type="url" value="{{ status.sonarr_url }}" placeholder="http://sonarr:8989"></label>
|
<label>Sonarr URL <input name="sonarr_url" type="url" value="{{ status.sonarr_url }}" placeholder="http://sonarr:8989"></label>
|
||||||
<label>API token <input name="sonarr_api_key" type="password" placeholder="{% if status.sonarr_api_key_configured %}Configured; enter a new token to replace{% else %}Sonarr API token{% endif %}" autocomplete="off"></label>
|
<label>API token <input name="sonarr_api_key" type="password" placeholder="{% if status.sonarr_api_key_configured %}Configured; enter a new token to replace{% else %}Sonarr API token{% endif %}" autocomplete="off"></label>
|
||||||
|
<button type="button" data-test-connection="sonarr">Test Sonarr connection</button><output id="sonarr-test-result"></output>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<p class="hint">Blank token fields clear the stored token. Environment values remain the startup defaults until saved here.</p>
|
<p class="hint">Blank token fields clear the stored token. Environment values remain the startup defaults until saved here.</p>
|
||||||
<button type="submit">Save settings</button>
|
<button type="submit">Save settings</button>
|
||||||
@@ -92,7 +95,7 @@
|
|||||||
<script>
|
<script>
|
||||||
const esc=value=>String(value??'').replace(/[&<>"']/g,ch=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[ch]));
|
const esc=value=>String(value??'').replace(/[&<>"']/g,ch=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[ch]));
|
||||||
async function postJson(url, body){ const response=await fetch(url,{method:'POST',headers:{'content-type':'application/json'},body:body?JSON.stringify(body):undefined}); if(!response.ok){ const error=await response.json().catch(()=>({detail:response.statusText})); alert(error.detail||'Request failed'); } return response; }
|
async function postJson(url, body){ const response=await fetch(url,{method:'POST',headers:{'content-type':'application/json'},body:body?JSON.stringify(body):undefined}); if(!response.ok){ const error=await response.json().catch(()=>({detail:response.statusText})); alert(error.detail||'Request failed'); } return response; }
|
||||||
function actionButtons(j){ const buttons=[]; if(j.can_retry) buttons.push(`<button type="button" data-action="retry" data-id="${j.id}">Retry</button>`); if(j.can_ignore) buttons.push(`<button type="button" data-action="ignore" data-id="${j.id}" class="warn">Ignore</button>`); if(j.can_remove) buttons.push(`<button type="button" data-action="remove" data-id="${j.id}" class="danger">Remove</button>`); return buttons.join(' '); }
|
function actionButtons(j){ const buttons=[]; if(j.can_run_now) buttons.push(`<button type="button" data-action="run-now" data-id="${j.id}">Run now</button>`); if(j.can_retry) buttons.push(`<button type="button" data-action="retry" data-id="${j.id}">Retry</button>`); if(j.can_ignore) buttons.push(`<button type="button" data-action="ignore" data-id="${j.id}" class="warn">Ignore</button>`); if(j.can_remove) buttons.push(`<button type="button" data-action="remove" data-id="${j.id}" class="danger">Remove</button>`); return buttons.join(' '); }
|
||||||
function renderJobs(data){ const groups=(data.groups||[]).filter(group=>group.jobs.length); if(!groups.length) return '<p>No queue items.</p>'; return groups.map(group=>`<section class="job-group"><h3>${esc(group.label)} <span>${group.jobs.length}</span></h3><table><thead><tr><th>File</th><th>Release / folder context</th><th>Readiness</th><th>SAB</th><th>Actions</th></tr></thead><tbody>${group.jobs.map(j=>`<tr><td><strong class="file-name">${esc(j.name)}</strong><small>${esc(j.source_type)}${j.batch_id?' · batch '+esc(j.batch_id):''}</small></td><td><small>${esc(j.relative_path||j.storage||j.source_id)}</small></td><td><span class="state">${esc(j.state)}</span><small>${esc(j.reason||'')}</small></td><td><small>${esc(j.sab_status||'—')}${j.sab_category?' · '+esc(j.sab_category):''}</small></td><td class="row-actions">${actionButtons(j)}</td></tr>`).join('')}</tbody></table></section>`).join(''); }
|
function renderJobs(data){ const groups=(data.groups||[]).filter(group=>group.jobs.length); if(!groups.length) return '<p>No queue items.</p>'; return groups.map(group=>`<section class="job-group"><h3>${esc(group.label)} <span>${group.jobs.length}</span></h3><table><thead><tr><th>File</th><th>Release / folder context</th><th>Readiness</th><th>SAB</th><th>Actions</th></tr></thead><tbody>${group.jobs.map(j=>`<tr><td><strong class="file-name">${esc(j.name)}</strong><small>${esc(j.source_type)}${j.batch_id?' · batch '+esc(j.batch_id):''}</small></td><td><small>${esc(j.relative_path||j.storage||j.source_id)}</small></td><td><span class="state">${esc(j.state)}</span><small>${esc(j.reason||'')}</small></td><td><small>${esc(j.sab_status||'—')}${j.sab_category?' · '+esc(j.sab_category):''}</small></td><td class="row-actions">${actionButtons(j)}</td></tr>`).join('')}</tbody></table></section>`).join(''); }
|
||||||
async function refresh(){ const r=await fetch('/api/jobs'); const d=await r.json(); document.title=d.jobs.length?`📥 ${d.jobs.length} jobs - Importarr`:'📥 - idle · Importarr'; document.getElementById('jobs').innerHTML=renderJobs(d); if(d.control){ document.getElementById('queue-mode').textContent=d.control.queue_mode; document.getElementById('current-job').textContent=d.control.current||'idle'; } }
|
async function refresh(){ const r=await fetch('/api/jobs'); const d=await r.json(); document.title=d.jobs.length?`📥 ${d.jobs.length} jobs - Importarr`:'📥 - idle · Importarr'; document.getElementById('jobs').innerHTML=renderJobs(d); if(d.control){ document.getElementById('queue-mode').textContent=d.control.queue_mode; document.getElementById('current-job').textContent=d.control.current||'idle'; } }
|
||||||
document.getElementById('jobs').addEventListener('click', async e=>{ const button=e.target.closest('button[data-action]'); if(!button)return; const action=button.dataset.action; const destructive=['ignore','remove'].includes(action); if(destructive&&!confirm(`${action} this Importarr queue item?`)) return; await postJson(`/api/queue-items/${button.dataset.id}/action`,{action}); await refresh(); });
|
document.getElementById('jobs').addEventListener('click', async e=>{ const button=e.target.closest('button[data-action]'); if(!button)return; const action=button.dataset.action; const destructive=['ignore','remove'].includes(action); if(destructive&&!confirm(`${action} this Importarr queue item?`)) return; await postJson(`/api/queue-items/${button.dataset.id}/action`,{action}); await refresh(); });
|
||||||
@@ -103,6 +106,7 @@
|
|||||||
document.getElementById('open-settings').addEventListener('click',()=>document.getElementById('settings-dialog').showModal());
|
document.getElementById('open-settings').addEventListener('click',()=>document.getElementById('settings-dialog').showModal());
|
||||||
document.getElementById('close-settings').addEventListener('click',()=>document.getElementById('settings-dialog').close());
|
document.getElementById('close-settings').addEventListener('click',()=>document.getElementById('settings-dialog').close());
|
||||||
document.getElementById('settings-form').addEventListener('submit', async e=>{ e.preventDefault(); const body=Object.fromEntries(new FormData(e.target)); const response=await postJson('/api/settings',body); if(response.ok){ const data=await response.json(); document.getElementById('sab-token-status').textContent=data.sab_api_key_configured?'configured':'not configured'; ['sab_api_key','radarr_api_key','sonarr_api_key'].forEach(name=>e.target.elements[name].value=''); document.getElementById('settings-dialog').close(); } });
|
document.getElementById('settings-form').addEventListener('submit', async e=>{ e.preventDefault(); const body=Object.fromEntries(new FormData(e.target)); const response=await postJson('/api/settings',body); if(response.ok){ const data=await response.json(); document.getElementById('sab-token-status').textContent=data.sab_api_key_configured?'configured':'not configured'; ['sab_api_key','radarr_api_key','sonarr_api_key'].forEach(name=>e.target.elements[name].value=''); document.getElementById('settings-dialog').close(); } });
|
||||||
|
document.querySelectorAll('[data-test-connection]').forEach(button=>button.addEventListener('click', async()=>{ const form=document.getElementById('settings-form'); const service=button.dataset.testConnection; const prefix=service==='sabnzbd'?'sab':service; const output=document.getElementById(`${service}-test-result`); output.textContent='Testing…'; output.className=''; const response=await postJson('/api/settings/test-connection',{service,url:form.elements[`${prefix}_url`].value,api_key:form.elements[`${prefix}_api_key`].value}); if(response.ok){ const data=await response.json(); output.textContent=data.message; output.className=data.ok?'success':'error'; } }));
|
||||||
document.getElementById('force-run').addEventListener('click', async()=>{ await postJson('/api/import/run-now',{force:true}); await refresh(); });
|
document.getElementById('force-run').addEventListener('click', async()=>{ await postJson('/api/import/run-now',{force:true}); await refresh(); });
|
||||||
refresh(); setInterval(refresh, 10000);
|
refresh(); setInterval(refresh, 10000);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -73,6 +73,28 @@ def test_queue_item_retry_ignore_and_remove_actions(tmp_path, monkeypatch):
|
|||||||
assert main.state.get_queue_item(row["id"]) is None
|
assert main.state.get_queue_item(row["id"]) is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_queue_item_run_now_imports_only_selected_item(tmp_path, monkeypatch):
|
||||||
|
main, download, movies, _tv = configure_main(tmp_path, monkeypatch)
|
||||||
|
batch = download / "Release"
|
||||||
|
batch.mkdir(parents=True)
|
||||||
|
selected = batch / "Selected.mkv"
|
||||||
|
waiting = batch / "Waiting.mkv"
|
||||||
|
selected.write_bytes(b"selected")
|
||||||
|
waiting.write_bytes(b"waiting")
|
||||||
|
selected_row = main.state.upsert_queue_item(source_type="manual", source_id=str(selected), source_path=selected, name=selected.name, state="manual_batch")
|
||||||
|
main.state.upsert_queue_item(source_type="manual", source_id=str(waiting), source_path=waiting, name=waiting.name, state="manual_batch")
|
||||||
|
|
||||||
|
result = main.queue_item_action(selected_row["id"], main.QueueItemActionRequest(action="run-now"))
|
||||||
|
|
||||||
|
assert result["status"] == "imported"
|
||||||
|
assert result["imported"] == 1
|
||||||
|
assert (movies / "Selected.mkv").read_bytes() == b"selected"
|
||||||
|
assert waiting.exists()
|
||||||
|
rows = {row["name"]: row for row in main.state.list_queue_items(active_only=False)}
|
||||||
|
assert rows["Selected.mkv"]["state"] == "imported"
|
||||||
|
assert rows["Waiting.mkv"]["state"] == "manual_batch"
|
||||||
|
|
||||||
|
|
||||||
def test_cancel_current_stops_before_next_manual_item(tmp_path, monkeypatch):
|
def test_cancel_current_stops_before_next_manual_item(tmp_path, monkeypatch):
|
||||||
main, download, movies, tv = configure_main(tmp_path, monkeypatch)
|
main, download, movies, tv = configure_main(tmp_path, monkeypatch)
|
||||||
batch = download / "Release"
|
batch = download / "Release"
|
||||||
|
|||||||
@@ -19,9 +19,44 @@ def test_completed_manual_is_ready():
|
|||||||
|
|
||||||
def test_wrong_category_ignored():
|
def test_wrong_category_ignored():
|
||||||
result = classify_history_item(item(category="*"), set(), "manual", ROOT)
|
result = classify_history_item(item(category="*"), set(), "manual", ROOT)
|
||||||
|
assert result.ready
|
||||||
|
assert result.reason == "SAB completed inside Importarr download root"
|
||||||
|
|
||||||
|
|
||||||
|
def test_wrong_category_outside_root_ignored():
|
||||||
|
result = classify_history_item(item(category="*", storage="/tmp/other/Movie"), set(), "manual", ROOT)
|
||||||
assert result.state == "ignored"
|
assert result.state == "ignored"
|
||||||
|
|
||||||
|
|
||||||
|
def test_sab_storage_root_maps_to_local_download_root():
|
||||||
|
result = classify_history_item(
|
||||||
|
item(category="*", storage="/data/downloads/manual/Movie"),
|
||||||
|
set(),
|
||||||
|
"manual",
|
||||||
|
ROOT,
|
||||||
|
sab_storage_root=Path("/data/downloads/manual"),
|
||||||
|
)
|
||||||
|
assert result.ready
|
||||||
|
assert result.storage == ROOT / "Movie"
|
||||||
|
|
||||||
|
|
||||||
|
def test_radarr_sonarr_storage_roots_are_not_importarr_owned():
|
||||||
|
for storage in ("/data/downloads/movies/Movie", "/data/downloads/tv/Show"):
|
||||||
|
result = classify_history_item(
|
||||||
|
item(category="*", storage=storage),
|
||||||
|
set(),
|
||||||
|
"manual",
|
||||||
|
ROOT,
|
||||||
|
sab_storage_root=Path("/data/downloads/manual"),
|
||||||
|
)
|
||||||
|
assert result.state == "ignored"
|
||||||
|
|
||||||
|
|
||||||
|
def test_sab_cat_field_is_treated_as_category():
|
||||||
|
result = classify_history_item(item(category=None, cat="manual"), set(), "manual", ROOT)
|
||||||
|
assert result.ready
|
||||||
|
|
||||||
|
|
||||||
def test_queue_item_not_ready():
|
def test_queue_item_not_ready():
|
||||||
result = classify_history_item(item(), {"1"}, "manual", ROOT)
|
result = classify_history_item(item(), {"1"}, "manual", ROOT)
|
||||||
assert result.state == "processing"
|
assert result.state == "processing"
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
from importarr.state import State
|
||||||
|
|
||||||
|
|
||||||
|
def test_delete_queue_items_by_state_can_target_reason(tmp_path):
|
||||||
|
state = State(tmp_path / "state.db")
|
||||||
|
state.upsert_queue_item(source_type="sab", source_id="stale", name="Stale", state="ignored", reason="SAB category is not owned by Importarr")
|
||||||
|
state.upsert_queue_item(source_type="sab", source_id="other", name="Other", state="ignored", reason="other reason")
|
||||||
|
|
||||||
|
assert state.delete_queue_items_by_state("sab", "ignored", "SAB category is not owned by Importarr") == 1
|
||||||
|
|
||||||
|
rows = state.list_queue_items()
|
||||||
|
assert len(rows) == 1
|
||||||
|
assert rows[0]["source_id"] == "other"
|
||||||
@@ -46,6 +46,9 @@ def test_index_renders_settings_dialog(tmp_path, monkeypatch):
|
|||||||
assert "SABnzbd" in response.text
|
assert "SABnzbd" in response.text
|
||||||
assert "Radarr" in response.text
|
assert "Radarr" in response.text
|
||||||
assert "Sonarr" in response.text
|
assert "Sonarr" in response.text
|
||||||
|
assert "Test SABnzbd connection" in response.text
|
||||||
|
assert "Test Radarr connection" in response.text
|
||||||
|
assert "Test Sonarr connection" in response.text
|
||||||
|
|
||||||
|
|
||||||
def test_settings_endpoint_persists_arr_connection_values(tmp_path, monkeypatch):
|
def test_settings_endpoint_persists_arr_connection_values(tmp_path, monkeypatch):
|
||||||
@@ -77,3 +80,37 @@ def test_settings_endpoint_persists_arr_connection_values(tmp_path, monkeypatch)
|
|||||||
}
|
}
|
||||||
assert main.settings.sab_api_key == "sab-secret"
|
assert main.settings.sab_api_key == "sab-secret"
|
||||||
assert main.state.get_app_state("radarr_api_key") == "radarr-secret"
|
assert main.state.get_app_state("radarr_api_key") == "radarr-secret"
|
||||||
|
|
||||||
|
|
||||||
|
def test_sab_connection_test_reports_success(tmp_path, monkeypatch):
|
||||||
|
monkeypatch.setenv("IMPORTARR_STATE_PATH", str(tmp_path / "state.db"))
|
||||||
|
import importarr.main as main
|
||||||
|
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
|
async def fake_queue(self):
|
||||||
|
return {"queue": {"slots": [{"name": "one"}, {"name": "two"}]}}
|
||||||
|
|
||||||
|
monkeypatch.setattr(main.SabnzbdClient, "queue", fake_queue)
|
||||||
|
|
||||||
|
response = TestClient(main.app).post(
|
||||||
|
"/api/settings/test-connection",
|
||||||
|
json={"service": "sabnzbd", "url": "http://sab:8080", "api_key": "secret"},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.json() == {"ok": True, "service": "sabnzbd", "message": "Connected to SABnzbd; 2 queued jobs visible."}
|
||||||
|
|
||||||
|
|
||||||
|
def test_connection_test_rejects_unknown_service(tmp_path, monkeypatch):
|
||||||
|
monkeypatch.setenv("IMPORTARR_STATE_PATH", str(tmp_path / "state.db"))
|
||||||
|
import importarr.main as main
|
||||||
|
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
|
response = TestClient(main.app).post(
|
||||||
|
"/api/settings/test-connection",
|
||||||
|
json={"service": "lidarr", "url": "http://lidarr:8686"},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
|||||||
Reference in New Issue
Block a user