from pathlib import Path

from app.config import settings
from app.services.media import MediaService
from app.services.repository import get_repository


class DiagnosticsService:
    def collect(self) -> dict:
        repo = get_repository()
        media = MediaService()
        return {
            'backend': repo.backend,
            'state_dir': settings.state_dir,
            'state_dir_exists': Path(settings.state_dir).exists(),
            'upload_tmp_dir': settings.upload_tmp_dir,
            'upload_tmp_dir_exists': Path(settings.upload_tmp_dir).exists(),
            'ffmpeg_path': media.ffmpeg_path(),
            'can_convert_audio': media.can_convert(),
            'n8n_base_url': settings.n8n_base_url,
            'paperless_base_url': settings.paperless_base_url,
            'd2l_scraper_workdir': settings.d2l_scraper_workdir,
        }
