pub mod binary;
pub mod extract;
pub mod hosts;
pub mod install;
pub mod process;
pub mod run;
use crate::config::YtdlpOptions;
use crate::error::YtdlpError;
use url::Url;
pub use binary::Tools;
pub use process::ManagedChild;
pub fn should_delegate(url: &Url, opts: &YtdlpOptions) -> bool {
opts.enabled() && hosts::is_delegated_url(url, opts.extra_hosts(), opts.excluded_hosts())
}
pub async fn tools(opts: &YtdlpOptions) -> Result<Tools, YtdlpError> {
binary::discover(opts).await
}
#[cfg(test)]
mod tests {
use super::*;
use crate::config::YtdlpOptionsBuilder;
#[test]
fn disabled_config_delegates_nothing() {
let opts = YtdlpOptionsBuilder::default()
.enabled(false)
.build()
.unwrap();
assert!(!should_delegate(
&Url::parse("https://www.youtube.com/watch?v=x").unwrap(),
&opts
));
}
#[test]
fn enabled_config_delegates_listed_hosts_only() {
let opts = YtdlpOptions::default();
assert!(should_delegate(
&Url::parse("https://www.youtube.com/watch?v=x").unwrap(),
&opts
));
assert!(!should_delegate(
&Url::parse("https://example.com/file.zip").unwrap(),
&opts
));
}
}