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

@ -16,6 +16,9 @@ pub enum Error {
/// Erroneous HTTP status code received
#[error("http status code: {0} message: {1}")]
HttpStatus(u16, Cow<'static, str>),
/// Authentication error
#[error("auth error: {0}")]
Auth(#[from] AuthError),
/// Unspecified error
#[error("error: {0}")]
Other(Cow<'static, str>),
@ -125,6 +128,25 @@ impl Display for UnavailabilityReason {
}
}
/// Error authenticating a YouTube user
#[derive(thiserror::Error, Debug)]
pub enum AuthError {
/// No user is logged in
#[error("you are not logged in")]
NoLogin,
/// The device code for user login has expired.
///
/// Generate a new device code and try again
#[error("device code expired; try again")]
DeviceCodeExpired,
/// The access token could not be refreshed
#[error("error refreshing token: {0}; log in again")]
Refresh(String),
/// Unhandled OAuth error
#[error("unhandled OAuth error: {0}")]
Other(String),
}
pub(crate) mod internal {
use super::{Error, ExtractionError};