feat: add OAuth user login to access age-restricted videos
This commit is contained in:
parent
7c4f44d09c
commit
1cc3f9ad74
6 changed files with 379 additions and 24 deletions
22
src/error.rs
22
src/error.rs
|
|
@ -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};
|
||||
|
||||
|
|
|
|||
Reference in a new issue