Files

31 lines
1.0 KiB
Python

import httpx
from app.config import settings
async def trigger_navidrome_scan() -> bool:
"""Notify Navidrome server to start scanning library for new files."""
if not settings.NAVIDROME_URL or not settings.NAVIDROME_USER:
return False
base_url = settings.NAVIDROME_URL.rstrip("/")
scan_url = f"{base_url}/rest/startScan.view"
params = {
"u": settings.NAVIDROME_USER,
"p": settings.NAVIDROME_PASSWORD,
"v": "1.16.1",
"c": "navidrome-music-sync",
"f": "json"
}
try:
async with httpx.AsyncClient(verify=False, timeout=10.0) as client:
resp = await client.get(scan_url, params=params)
if resp.status_code == 200:
print("Navidrome library scan initiated successfully.")
return True
else:
print(f"Navidrome scan request returned status {resp.status_code}")
except Exception as e:
print(f"Failed to trigger Navidrome scan: {e}")
return False