diff --git a/cli/README.md b/cli/README.md index e6d6c27..b4056c4 100644 --- a/cli/README.md +++ b/cli/README.md @@ -146,6 +146,7 @@ Fetch a list of all the items saved in your YouTube/YouTube Music profile. given path for generating PO tokens - `--no-botguard` Disable Botguard, only download videos using clients that dont require it +- `--pot-cache` Enable caching for session-bound PO tokens ### Output format diff --git a/cli/src/main.rs b/cli/src/main.rs index 7b5d15a..7f49119 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -72,7 +72,7 @@ struct Cli { no_botguard: bool, /// Enable caching for session-bound PO tokens #[clap(long, global = true)] - po_token_cache: bool, + pot_cache: bool, } #[derive(Parser)] @@ -916,7 +916,7 @@ async fn run() -> anyhow::Result<()> { if cli.no_botguard { rp = rp.no_botguard(); } - if cli.po_token_cache { + if cli.pot_cache { rp = rp.po_token_cache(); } if cli.auth { diff --git a/downloader/src/error.rs b/downloader/src/error.rs index c9ad088..d45405d 100644 --- a/downloader/src/error.rs +++ b/downloader/src/error.rs @@ -13,8 +13,13 @@ pub enum DownloadError { #[error("http error: {0}")] Http(#[from] reqwest::Error), /// 403 error trying to download video - #[error("YouTube returned 403 error; visitor_data={}", .1.as_deref().unwrap_or_default())] - Forbidden(ClientType, Option), + #[error("YouTube returned 403 error; visitor_data={}", .visitor_data.as_deref().unwrap_or_default())] + Forbidden { + /// Client type used to fetch the failed stream + client_type: ClientType, + /// Visitor data used to fetch the failed stream + visitor_data: Option, + }, /// File IO error #[error(transparent)] Io(#[from] std::io::Error), diff --git a/downloader/src/lib.rs b/downloader/src/lib.rs index fc6cf8f..8dc00c0 100644 --- a/downloader/src/lib.rs +++ b/downloader/src/lib.rs @@ -660,9 +660,15 @@ impl DownloadQuery { .await { Ok(res) => return Ok(res), - Err(DownloadError::Forbidden(c, vd)) => { - failed_client = Some(c); - DownloadError::Forbidden(c, vd) + Err(DownloadError::Forbidden { + client_type, + visitor_data, + }) => { + failed_client = Some(client_type); + DownloadError::Forbidden { + client_type, + visitor_data, + } } Err(DownloadError::Http(e)) => { if !e.is_timeout() { @@ -842,10 +848,10 @@ impl DownloadQuery { if let Some(vd) = &player_data.visitor_data { q.remove_visitor_data(vd); } - return DownloadError::Forbidden( - player_data.client_type, - player_data.visitor_data.clone(), - ); + return DownloadError::Forbidden { + client_type: player_data.client_type, + visitor_data: player_data.visitor_data.clone(), + }; } } e