feat: add UnavailabilityReason: IpBan
This commit is contained in:
parent
53829c543f
commit
401d4e8255
2 changed files with 8 additions and 4 deletions
|
|
@ -180,6 +180,7 @@ impl MapResponse<VideoPlayer> for response::Player {
|
||||||
"members-only" => Some(UnavailabilityReason::MembersOnly),
|
"members-only" => Some(UnavailabilityReason::MembersOnly),
|
||||||
"country" => Some(UnavailabilityReason::Geoblocked),
|
"country" => Some(UnavailabilityReason::Geoblocked),
|
||||||
"Android" | "websites" => Some(UnavailabilityReason::UnsupportedClient),
|
"Android" | "websites" => Some(UnavailabilityReason::UnsupportedClient),
|
||||||
|
"bot" => Some(UnavailabilityReason::IpBan),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
|
||||||
11
src/error.rs
11
src/error.rs
|
|
@ -31,7 +31,7 @@ pub enum ExtractionError {
|
||||||
/// - Age restriction
|
/// - Age restriction
|
||||||
/// - Private video
|
/// - Private video
|
||||||
/// - DRM (Movies and TV shows)
|
/// - DRM (Movies and TV shows)
|
||||||
#[error("content unavailable because it is {reason}. Reason (from YT): {msg}")]
|
#[error("content unavailable ({reason}). Reason (from YT): {msg}")]
|
||||||
Unavailable {
|
Unavailable {
|
||||||
/// Reason why the video could not be extracted
|
/// Reason why the video could not be extracted
|
||||||
reason: UnavailabilityReason,
|
reason: UnavailabilityReason,
|
||||||
|
|
@ -100,6 +100,8 @@ pub enum UnavailabilityReason {
|
||||||
MembersOnly,
|
MembersOnly,
|
||||||
/// Livestream has gone offline
|
/// Livestream has gone offline
|
||||||
OfflineLivestream,
|
OfflineLivestream,
|
||||||
|
/// YouTube banned your IP address from accessing the platform without an account
|
||||||
|
IpBan,
|
||||||
/// Video cant be played for other reasons
|
/// Video cant be played for other reasons
|
||||||
#[default]
|
#[default]
|
||||||
Unplayable,
|
Unplayable,
|
||||||
|
|
@ -108,15 +110,16 @@ pub enum UnavailabilityReason {
|
||||||
impl Display for UnavailabilityReason {
|
impl Display for UnavailabilityReason {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
UnavailabilityReason::AgeRestricted => f.write_str("age restriction"),
|
UnavailabilityReason::AgeRestricted => f.write_str("age-restricted"),
|
||||||
UnavailabilityReason::Deleted => f.write_str("deleted"),
|
UnavailabilityReason::Deleted => f.write_str("deleted"),
|
||||||
UnavailabilityReason::Geoblocked => f.write_str("geoblocking"),
|
UnavailabilityReason::Geoblocked => f.write_str("geoblocked"),
|
||||||
UnavailabilityReason::UnsupportedClient => f.write_str("unsupported by client"),
|
UnavailabilityReason::UnsupportedClient => f.write_str("unsupported by client"),
|
||||||
UnavailabilityReason::Private => f.write_str("private"),
|
UnavailabilityReason::Private => f.write_str("private"),
|
||||||
UnavailabilityReason::Paid => f.write_str("paid"),
|
UnavailabilityReason::Paid => f.write_str("paid"),
|
||||||
UnavailabilityReason::Premium => f.write_str("premium-only"),
|
UnavailabilityReason::Premium => f.write_str("premium-only"),
|
||||||
UnavailabilityReason::MembersOnly => f.write_str("members-only"),
|
UnavailabilityReason::MembersOnly => f.write_str("members-only"),
|
||||||
UnavailabilityReason::OfflineLivestream => f.write_str("an offline stream"),
|
UnavailabilityReason::OfflineLivestream => f.write_str("offline stream"),
|
||||||
|
UnavailabilityReason::IpBan => f.write_str("ip-ban"),
|
||||||
UnavailabilityReason::Unplayable => f.write_str("unplayable"),
|
UnavailabilityReason::Unplayable => f.write_str("unplayable"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue