eebc86a52b
Add a shared ServiceBaseUrl type (BeforeValidator + Field description) in integrations/base.py and apply it to base_url across all six service configs (grafana, prometheus, alertmanager, jellyfin, jellyseerr, nextcloud). Missing http:// or https:// schema now fails fast with a clear 422 instead of breaking HTTP clients silently. Tests cover reject/accept cases; REQUIREMENTS updated.
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
"""Jellyfin service definition."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from media_library_viewer_api.integrations.base import (
|
|
SecretField,
|
|
ServiceBaseUrl,
|
|
ServiceConfigBase,
|
|
ServiceDefinition,
|
|
WidgetConfigBase,
|
|
widget_kind,
|
|
)
|
|
|
|
|
|
class JellyfinConfig(ServiceConfigBase):
|
|
"""Non-secret Jellyfin connection config."""
|
|
|
|
base_url: ServiceBaseUrl
|
|
user_id: str = ""
|
|
timeout_seconds: int = 10
|
|
|
|
|
|
class JellyfinActivityWidgetConfig(WidgetConfigBase):
|
|
"""Live Jellyfin session activity."""
|
|
|
|
# No user-overridable fields; the service record carries user_id.
|
|
pass
|
|
|
|
|
|
DEFINITION = ServiceDefinition(
|
|
service_type="jellyfin",
|
|
name="Jellyfin",
|
|
description="Media server with live session activity.",
|
|
config_model=JellyfinConfig,
|
|
secret_fields=[
|
|
SecretField(key="api_key", label="API key", required=True),
|
|
],
|
|
widget_kinds=[
|
|
widget_kind(
|
|
kind="activity",
|
|
name="Activity",
|
|
description="Live sessions and idle users.",
|
|
model_cls=JellyfinActivityWidgetConfig,
|
|
default_config={},
|
|
refresh_interval_ms=30_000,
|
|
),
|
|
],
|
|
)
|