mirror of
https://github.com/HabiRabbu/Musicseerr
synced 2026-04-21 13:37:27 +00:00
parent
48c0a94a47
commit
e76ed59b44
2 changed files with 17 additions and 2 deletions
|
|
@ -22,6 +22,12 @@ class Settings(BaseSettings):
|
|||
|
||||
lidarr_url: str = Field(default="http://lidarr:8686")
|
||||
lidarr_api_key: str = Field(default="")
|
||||
lidarr_timeout: float = Field(
|
||||
default=30.0,
|
||||
ge=5.0,
|
||||
le=600.0,
|
||||
description="HTTP read/write timeout in seconds for Lidarr API calls.",
|
||||
)
|
||||
|
||||
jellyfin_url: str = Field(default="http://jellyfin:8096")
|
||||
|
||||
|
|
@ -192,6 +198,7 @@ class Settings(BaseSettings):
|
|||
config_data = {
|
||||
"lidarr_url": self.lidarr_url,
|
||||
"lidarr_api_key": self.lidarr_api_key,
|
||||
"lidarr_timeout": self.lidarr_timeout,
|
||||
"jellyfin_url": self.jellyfin_url,
|
||||
"contact_email": self.contact_email,
|
||||
"quality_profile_id": self.quality_profile_id,
|
||||
|
|
@ -221,6 +228,7 @@ class Settings(BaseSettings):
|
|||
config_data.update({
|
||||
"lidarr_url": self.lidarr_url,
|
||||
"lidarr_api_key": self.lidarr_api_key,
|
||||
"lidarr_timeout": self.lidarr_timeout,
|
||||
"jellyfin_url": self.jellyfin_url,
|
||||
"contact_email": self.contact_email,
|
||||
"quality_profile_id": self.quality_profile_id,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class LidarrBase:
|
|||
|
||||
@property
|
||||
def _base_url(self) -> str:
|
||||
return self._settings.lidarr_url
|
||||
return self._settings.lidarr_url.rstrip("/")
|
||||
|
||||
def is_configured(self) -> bool:
|
||||
return bool(self._settings.lidarr_api_key)
|
||||
|
|
@ -78,7 +78,13 @@ class LidarrBase:
|
|||
if not self.is_configured():
|
||||
raise ExternalServiceError("Lidarr is not configured (no API key)")
|
||||
|
||||
url = f"{self._base_url}{endpoint}"
|
||||
path = endpoint.lstrip("/")
|
||||
url = f"{self._base_url}/{path}" if path else self._base_url
|
||||
|
||||
timeout = httpx.Timeout(
|
||||
self._settings.lidarr_timeout,
|
||||
connect=self._settings.http_connect_timeout,
|
||||
)
|
||||
|
||||
try:
|
||||
response = await self._client.request(
|
||||
|
|
@ -87,6 +93,7 @@ class LidarrBase:
|
|||
headers=self._get_headers(),
|
||||
params=params,
|
||||
json=json_data,
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
if method == "DELETE" and response.status_code in (200, 202, 204):
|
||||
|
|
|
|||
Loading…
Reference in a new issue