Binaries¶
AsyncYT - A comprehensive async Any website downloader library Uses yt-dlp and ffmpeg with automatic binary management
- class asyncyt.binaries.AsyncFFmpeg(setup_only_ffmpeg: bool = True, bin_dir: str | Path | None = None)[source]¶
Bases:
BinaryManager
AsyncFFmpeg: binary manager for media processing tasks.
This class provides asynchronous methods to interact with FFmpeg and ffprobe binaries, enabling media file analysis, format conversion, codec compatibility checks, and progress reporting. It is designed to facilitate efficient and robust media processing workflows, including support for thumbnail embedding, output file management, and error handling.
- Parameters:
setup_only_ffmpeg (bool) – If True, only sets up FFmpeg binary. Defaults to True.
bin_dir (Optional[str | Path]) – Directory containing FFmpeg binaries. Defaults to None.
- async get_file_info(file_path: str) MediaInfo [source]¶
Asynchronously retrieve media file information using ffprobe.
- Parameters:
file_path (str) – Path to the media file to be analyzed.
- Returns:
MediaInfo object containing metadata about the media file.
- Return type:
- Raises:
FFmpegProcessingError – If ffprobe fails to process the file or returns a non-zero exit code.
- async process(file: str, ffmpeg_config: FFmpegConfig, config: DownloadConfig | None = None, progress_callback: Callable[[DownloadProgress], None | Awaitable[None]] | None = None, progress: DownloadProgress | None = None, url: str | None = None)[source]¶
Asynchronously process a media file using FFmpeg, handling format conversion, codec compatibility, and progress reporting.
- Parameters:
file (str) – Path to the input media file.
ffmpeg_config (FFmpegConfig) – Configuration object for FFmpeg processing.
config (Optional[DownloadConfig]) – Download configuration, including output path and format settings.
progress_callback (Optional[Callable[[DownloadProgress], Union[None, Awaitable[None]]]]) – Callback function to report progress updates.
progress (Optional[DownloadProgress]) – Initial progress state, if available.
url (Optional[str]) – Source URL of the media file.
- Returns:
Filename of the processed output file.
- Return type:
str
- Raises:
CodecCompatibilityError – If the desired codec and format are incompatible and error raising is enabled.
FFmpegOutputExistsError – If the output file already exists and overwriting is disabled.
FFmpegProcessingError – If FFmpeg returns a non-zero exit code during processing.
- class asyncyt.binaries.BinaryManager(bin_dir: str | Path | None = None)[source]¶
Bases:
object
Main Manager for managing binaries.
- Parameters:
bin_dir (Optional[str | Path]) – Directory for binary files (yt-dlp, ffmpeg).
- async health_check() HealthResponse [source]¶
Perform a health check on the required binaries (yt-dlp and ffmpeg).
- Returns:
HealthResponse object with health status and binary availability.
- Return type:
- Raises:
Exception – If an unexpected error occurs during the health check process.
- async setup_binaries_generator() AsyncGenerator[SetupProgress, Any] [source]¶
Download and setup yt-dlp and ffmpeg binaries, yielding SetupProgress.
- Returns:
Async generator yielding SetupProgress objects.
- Return type:
AsyncGenerator[SetupProgress, Any]