# Copyright 2025-2026 Yakhyokhuja Valikhujaev # Author: Yakhyokhuja Valikhujaev # GitHub: https://github.com/yakhyo from __future__ import annotations from pathlib import Path IMAGE_EXTENSIONS = {'.jpg', '.jpeg', '.png', '.bmp', '.webp', '.tiff'} VIDEO_EXTENSIONS = {'.mp4', '.avi', '.mov', '.mkv', '.webm', '.flv'} def get_source_type(source: str) -> str: """Determine if source is image, video, or camera. Args: source: File path or camera ID string (e.g. ``"0"``). Returns: One of ``"image"``, ``"video"``, ``"camera"``, or ``"unknown"``. """ if source.isdigit(): return 'camera' suffix = Path(source).suffix.lower() if suffix in IMAGE_EXTENSIONS: return 'image' if suffix in VIDEO_EXTENSIONS: return 'video' return 'unknown'