1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Statistics and analytics for download and metadata fetch operations.
//!
//! When the `statistics` feature is enabled, the library automatically tracks
//! aggregate metrics for every download and metadata fetch. The [`StatisticsTracker`]
//! subscribes to the [`crate::events::EventBus`] in a background task and maintains
//! running counters, so no polling or manual bookkeeping is required.
//!
//! Access the tracker through [`crate::Downloader::statistics`] and call
//! [`StatisticsTracker::snapshot`] to obtain a point-in-time [`GlobalSnapshot`].
//!
//! # Example
//!
//! ```rust,no_run
//! use std::path::PathBuf;
//!
//! use yt_dlp::Downloader;
//! use yt_dlp::client::deps::Libraries;
//!
//! #[tokio::main]
//! async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
//! let libraries = Libraries::new(PathBuf::from("libs/yt-dlp"), PathBuf::from("libs/ffmpeg"));
//! let downloader = Downloader::builder(libraries, "output").build().await?;
//!
//! // ... perform downloads and fetches ...
//!
//! let snapshot = downloader.statistics().snapshot().await;
//! println!("Completed: {}", snapshot.downloads.completed);
//! println!("Total bytes: {}", snapshot.downloads.total_bytes);
//! println!(
//! "Avg speed (B/s): {:?}",
//! snapshot.downloads.avg_speed_bytes_per_sec
//! );
//! println!("Fetch success %: {:?}", snapshot.fetches.success_rate);
//! Ok(())
//! }
//! ```
pub use TrackerConfig;
pub use ;
pub use StatisticsTracker;