62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
from typing import Any, Dict, Optional
|
|
import httpx
|
|
from .base import ApiClient
|
|
|
|
|
|
class JellyseerrClient(ApiClient):
|
|
async def get_status(self) -> Optional[Dict[str, Any]]:
|
|
return await self.get("/api/v1/status")
|
|
|
|
async def get_request(self, request_id: str) -> Optional[Dict[str, Any]]:
|
|
return await self.get(f"/api/v1/request/{request_id}")
|
|
|
|
async def get_recent_requests(self, take: int = 10, skip: int = 0) -> Optional[Dict[str, Any]]:
|
|
return await self.get(
|
|
"/api/v1/request",
|
|
params={
|
|
"take": take,
|
|
"skip": skip,
|
|
},
|
|
)
|
|
|
|
async def get_movie(self, tmdb_id: int) -> Optional[Dict[str, Any]]:
|
|
return await self.get(f"/api/v1/movie/{tmdb_id}")
|
|
|
|
async def get_tv(self, tmdb_id: int) -> Optional[Dict[str, Any]]:
|
|
return await self.get(f"/api/v1/tv/{tmdb_id}")
|
|
|
|
async def search(self, query: str, page: int = 1) -> Optional[Dict[str, Any]]:
|
|
return await self.get(
|
|
"/api/v1/search",
|
|
params={
|
|
"query": query,
|
|
"page": page,
|
|
},
|
|
)
|
|
|
|
async def get_users(self, take: int = 50, skip: int = 0) -> Optional[Dict[str, Any]]:
|
|
return await self.get(
|
|
"/api/v1/user",
|
|
params={
|
|
"take": take,
|
|
"skip": skip,
|
|
},
|
|
)
|
|
|
|
async def get_user(self, user_id: int) -> Optional[Dict[str, Any]]:
|
|
return await self.get(f"/api/v1/user/{user_id}")
|
|
|
|
async def delete_user(self, user_id: int) -> Optional[Dict[str, Any]]:
|
|
return await self.delete(f"/api/v1/user/{user_id}")
|
|
|
|
async def login_local(self, email: str, password: str) -> Optional[Dict[str, Any]]:
|
|
payload = {"email": email, "password": password}
|
|
try:
|
|
return await self.post("/api/v1/auth/local", payload=payload)
|
|
except httpx.HTTPStatusError as exc:
|
|
# Backward compatibility for older Seerr/Overseerr deployments
|
|
# that still expose /auth/login instead of /auth/local.
|
|
if exc.response is not None and exc.response.status_code in {404, 405}:
|
|
return await self.post("/api/v1/auth/login", payload=payload)
|
|
raise
|