tests: add tests for YT internal channels, remove RSS default feature

This commit is contained in:
ThetaDev 2022-10-12 21:17:54 +02:00
parent de118c59c4
commit 62853d50bf
6 changed files with 90 additions and 60 deletions

View file

@ -383,11 +383,13 @@ fn map_channel<T>(
id: &str,
lang: Language,
) -> Result<Channel<T>, ExtractionError> {
let header = header.ok_or(ExtractionError::NoData)?;
let header =
header.ok_or_else(|| ExtractionError::ContentUnavailable("channel not found".into()))?;
let metadata = metadata
.ok_or(ExtractionError::NoData)?
.ok_or_else(|| ExtractionError::ContentUnavailable("channel not found".into()))?
.channel_metadata_renderer;
let microformat = microformat.ok_or(ExtractionError::NoData)?;
let microformat = microformat
.ok_or_else(|| ExtractionError::ContentUnavailable("channel not found".into()))?;
if metadata.external_id != id {
return Err(ExtractionError::WrongResult(format!(
@ -463,7 +465,9 @@ fn map_channel_content(
Some(contents) => {
let tabs = contents.two_column_browse_results_renderer.tabs;
if tabs.is_empty() {
return Err(ExtractionError::NoData);
return Err(ExtractionError::ContentUnavailable(
"channel not found".into(),
));
}
let (channel_content, target_id) = tabs

View file

@ -1095,7 +1095,6 @@ impl RustyPipeQuery {
ExtractionError::VideoUnavailable(_, _)
| ExtractionError::VideoAgeRestricted
| ExtractionError::ContentUnavailable(_)
| ExtractionError::NoData
| ExtractionError::Retry => (),
_ => create_report(Level::ERR, Some(e.to_string()), Vec::new()),
}

View file

@ -506,9 +506,10 @@ pub fn alerts_to_err(alerts: Option<Vec<Alert>>) -> ExtractionError {
.into_iter()
.map(|a| a.alert_renderer.text)
.collect::<Vec<_>>()
.join(" "),
.join(" ")
.into(),
),
None => ExtractionError::InvalidData("no contents".into()),
None => ExtractionError::ContentUnavailable("content not found".into()),
}
}

View file

@ -75,10 +75,8 @@ pub enum ExtractionError {
VideoUnavailable(&'static str, String),
#[error("Video is age restricted")]
VideoAgeRestricted,
#[error("Content is not available. Reason (from YT): {0}")]
ContentUnavailable(String),
#[error("Got no data from YouTube")]
NoData,
#[error("Content is not available. Reason: {0}")]
ContentUnavailable(Cow<'static, str>),
#[error("deserialization error: {0}")]
Deserialization(#[from] serde_json::Error),
#[error("got invalid data from YT: {0}")]