feat!: add channel_videos_tab, channel_videos_order,

remove channel_shorts, channel_livestreams
fix: parsing video types and short durations
This commit is contained in:
ThetaDev 2023-05-11 14:13:54 +02:00
parent 7e5cff719a
commit 3a75ed8610
20 changed files with 444 additions and 152 deletions

View file

@ -7,3 +7,34 @@ pub mod search_filter;
pub use locale::{Country, Language};
pub use stream_filter::StreamFilter;
/// Channel video tab
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ChannelVideoTab {
/// Regular videos
Videos,
/// Short videos
Shorts,
/// Livestreams
Live,
}
/// Sort order for channel videos
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ChannelOrder {
/// Order videos with the latest upload date first (default)
Latest = 1,
/// Order videos with the highest number of views first
Popular = 2,
}
impl ChannelVideoTab {
/// Get the tab ID used to create ordered continuation tokens
pub(crate) const fn order_ctoken_id(&self) -> u32 {
match self {
ChannelVideoTab::Videos => 15,
ChannelVideoTab::Shorts => 10,
ChannelVideoTab::Live => 14,
}
}
}

View file

@ -2,7 +2,7 @@
use std::collections::BTreeSet;
use crate::util::{self, ProtoBuilder};
use crate::util::ProtoBuilder;
/// YouTube search filter
///
@ -200,8 +200,7 @@ impl SearchFilter {
pb.embedded(8, extras)
}
let b64 = util::b64_encode(pb.bytes);
urlencoding::encode(&b64).to_string()
pb.to_base64()
}
}