feat: add OAuth user login to access age-restricted videos

This commit is contained in:
ThetaDev 2024-10-23 23:00:26 +02:00
parent 7c4f44d09c
commit 1cc3f9ad74
No known key found for this signature in database
GPG key ID: E319D3C5148D65B6
6 changed files with 379 additions and 24 deletions

View file

@ -191,6 +191,8 @@ enum Commands {
},
/// Get a YouTube visitor data cookie
Vdata,
/// Log in using your Google account
Login,
}
#[derive(Default, Copy, Clone, ValueEnum)]
@ -1208,6 +1210,22 @@ async fn run() -> anyhow::Result<()> {
let vd = rp.query().get_visitor_data().await?;
println!("{vd}");
}
Commands::Login => {
match rp.user_auth_check_login().await {
Ok(_) => {}
Err(rustypipe::error::Error::Auth(_)) => {
let device_code = rp.user_auth_get_code().await?;
println!(
"Open {} and enter the following code:",
device_code.verification_url
);
anstream::println!("{}", device_code.user_code.blue());
rp.user_auth_wait_for_login(&device_code).await?;
}
Err(e) => return Err(e.into()),
}
anstream::println!("{}", "Logged in.".green());
}
};
Ok(())
}