fix: handle playlist not found

This commit is contained in:
ThetaDev 2022-10-11 19:50:43 +02:00
parent de9e3c6ed9
commit 79b7fcf92c
5 changed files with 49 additions and 23 deletions

View file

@ -25,6 +25,7 @@ pub use channel_rss::ChannelRss;
use serde::Deserialize;
use serde_with::{json::JsonString, serde_as, DefaultOnError, VecSkipError};
use crate::error::ExtractionError;
use crate::serializer::{
ignore_any,
text::{Text, TextComponent},
@ -471,3 +472,16 @@ impl IsShort for Vec<TimeOverlay> {
})
}
}
pub fn alerts_to_err(alerts: Option<Vec<Alert>>) -> ExtractionError {
match alerts {
Some(alerts) => ExtractionError::ContentUnavailable(
alerts
.into_iter()
.map(|a| a.alert_renderer.text)
.collect::<Vec<_>>()
.join(" "),
),
None => ExtractionError::InvalidData("no contents".into()),
}
}