feat: add channel playlists
- add tests for channel videos - small model refactor (rename Channel to ChannelTag)
This commit is contained in:
parent
45707c4d01
commit
6f1a1c4440
30 changed files with 16831 additions and 241 deletions
|
|
@ -41,6 +41,25 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> MapResult<T>
|
||||
where
|
||||
T: Default,
|
||||
{
|
||||
pub fn error(msg: String) -> Self {
|
||||
Self {
|
||||
c: T::default(),
|
||||
warnings: vec![msg],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ok(c: T) -> Self {
|
||||
Self {
|
||||
c,
|
||||
warnings: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Deserialization method that consumes anything and returns an empty value.
|
||||
/// Intended to be used for a wildcard enum option.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -225,8 +225,10 @@ pub enum PageType {
|
|||
Playlist,
|
||||
}
|
||||
|
||||
fn map_richtext_run(run: RichTextRun) -> TextComponent {
|
||||
map_text_component(run.text, run.navigation_endpoint)
|
||||
impl From<RichTextRun> for TextComponent {
|
||||
fn from(run: RichTextRun) -> Self {
|
||||
map_text_component(run.text, run.navigation_endpoint)
|
||||
}
|
||||
}
|
||||
|
||||
/// Map a single component of a rich text
|
||||
|
|
@ -270,7 +272,7 @@ impl<'de> Deserialize<'de> for TextComponent {
|
|||
));
|
||||
}
|
||||
|
||||
Ok(map_richtext_run(text.runs.swap_remove(0)))
|
||||
Ok(text.runs.swap_remove(0).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +282,9 @@ impl<'de> Deserialize<'de> for TextComponents {
|
|||
D: Deserializer<'de>,
|
||||
{
|
||||
let text = RichTextInternal::deserialize(deserializer)?;
|
||||
Ok(Self(text.runs.into_iter().map(map_richtext_run).collect()))
|
||||
Ok(Self(
|
||||
text.runs.into_iter().map(TextComponent::from).collect(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +299,7 @@ impl<'de> DeserializeAs<'de, TextComponents> for AttributedText {
|
|||
let mut chars = text.content.chars();
|
||||
|
||||
// Take a string from the char iterator until the given
|
||||
// UTF-16 index. This mimicks the Javascript substring behavior.
|
||||
// UTF-16 index. This mimics the Javascript substring behavior.
|
||||
let mut take_chars = |until: usize| {
|
||||
if until <= i_utf16 {
|
||||
return String::new();
|
||||
|
|
@ -338,7 +342,7 @@ impl<'de> DeserializeAs<'de, TextComponents> for AttributedText {
|
|||
let txt_link = txt_link.trim();
|
||||
let txt_link = txt_link.replace("\u{a0}", " ");
|
||||
|
||||
static LINK_PREFIX: Lazy<Regex> = Lazy::new(|| Regex::new(r#"^(?:\/|•) *"#).unwrap());
|
||||
static LINK_PREFIX: Lazy<Regex> = Lazy::new(|| Regex::new("^[/•] *").unwrap());
|
||||
let txt_link = LINK_PREFIX.replace(&txt_link, "");
|
||||
|
||||
if !txt_before.is_empty() {
|
||||
|
|
|
|||
Reference in a new issue