feat: add more extraction errors

This commit is contained in:
ThetaDev 2022-11-04 21:28:13 +01:00
parent f748b98ccc
commit 68342cecab
4 changed files with 78 additions and 25 deletions

View file

@ -73,6 +73,10 @@ pub enum ExtractionError {
VideoUnavailable(&'static str, String),
#[error("Video is age restricted")]
VideoAgeRestricted,
#[error("Video is not available in your country")]
VideoGeoblock,
#[error("Video cant be played with this client. Reason (from YT): {0}")]
VideoClientUnsupported(String),
#[error("Content is not available. Reason: {0}")]
ContentUnavailable(Cow<'static, str>),
#[error("deserialization error: {0}")]
@ -84,3 +88,23 @@ pub enum ExtractionError {
#[error("Warnings during deserialization/mapping")]
DeserializationWarnings,
}
impl ExtractionError {
pub(crate) fn should_report(&self) -> bool {
matches!(
self,
ExtractionError::Deserialization(_)
| ExtractionError::InvalidData(_)
| ExtractionError::WrongResult(_)
)
}
pub(crate) fn switch_client(&self) -> bool {
matches!(
self,
ExtractionError::VideoClientUnsupported(_)
| ExtractionError::VideoAgeRestricted
| ExtractionError::WrongResult(_)
)
}
}