24 lines
726 B
Python
24 lines
726 B
Python
import httpx
|
|
|
|
from app.config import Settings
|
|
|
|
|
|
class JellyfinRefreshSkipped(RuntimeError):
|
|
pass
|
|
|
|
|
|
async def refresh_jellyfin(settings: Settings) -> bool:
|
|
"""Trigger Jellyfin's library refresh when credentials are configured.
|
|
|
|
Returns False when no API key is present so local/dev imports can still finish
|
|
without writing secrets into the project tree.
|
|
"""
|
|
if not settings.jellyfin_api_key:
|
|
return False
|
|
url = settings.jellyfin_url.rstrip("/") + "/Library/Refresh"
|
|
headers = {"X-Emby-Token": settings.jellyfin_api_key}
|
|
async with httpx.AsyncClient(timeout=20) as client:
|
|
response = await client.post(url, headers=headers)
|
|
response.raise_for_status()
|
|
return True
|