from __future__ import annotations

import logging

from moviebot.http import HttpClient


class JellyfinScanBot:
    def __init__(self, config: dict, http: HttpClient):
        self.config = config
        self.http = http
        self.log = logging.getLogger(self.__class__.__name__)

    def scan(self) -> None:
        base_url = (self.config.get("base_url") or "").rstrip("/")
        api_key = self.config.get("api_key") or ""
        if not base_url or not api_key:
            self.log.info("Jellyfin scan skipped; base_url or api_key is missing")
            return
        self.http.get(f"{base_url}/Library/Refresh", headers={"X-Emby-Token": api_key})
        self.log.info("Requested Jellyfin library refresh")

