Index: Cargo.lock ================================================================== --- Cargo.lock +++ Cargo.lock @@ -1965,11 +1965,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "yaydl" -version = "0.12.1" +version = "0.12.2" dependencies = [ "anyhow", "cienli", "clap", "env_proxy", Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -1,9 +1,9 @@ [package] name = "yaydl" description = "yet another youtube (and more) down loader" -version = "0.12.1" +version = "0.12.2" authors = ["Cthulhux "] edition = "2021" license = "CDDL-1.0" repository = "https://code.rosaelefanten.org/yaydl" categories = ["command-line-utilities"] Index: src/handlers/youtube.rs ================================================================== --- src/handlers/youtube.rs +++ src/handlers/youtube.rs @@ -19,18 +19,28 @@ use crate::definitions::SiteDefinition; use anyhow::Result; use regex::Regex; use serde_json::{json, Value}; +use url::Url; use crate::VIDEO; fn get_video_info(video: &mut VIDEO, id: &str) -> Result { if video.info.is_empty() { // We need to fetch the video information first. + let mut agent = ureq::agent(); let video_url = "https://youtubei.googleapis.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"; - let req = ureq::post(&video_url).send_json(ureq::json!({ + let url_p = Url::parse(video_url)?; + + if let Some(env_proxy) = env_proxy::for_url(&url_p).host_port() { + // Use a proxy: + let proxy = ureq::Proxy::new(format!("{}:{}", env_proxy.0, env_proxy.1)); + agent = ureq::AgentBuilder::new().proxy(proxy.unwrap()).build(); + } + + let req = agent.post(&video_url).send_json(ureq::json!({ "videoId": id, "context": { "client": { "clientName": "ANDROID", "clientVersion": "16.02"