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

@ -83,6 +83,18 @@ pub fn generate_content_playback_nonce() -> String {
random_string(CONTENT_PLAYBACK_NONCE_ALPHABET, 16)
}
pub fn random_uuid() -> String {
let mut rng = rand::thread_rng();
format!(
"{:08x}-{:04x}-{:04x}-{:04x}-{:012x}",
rng.gen::<u32>(),
rng.gen::<u16>(),
rng.gen::<u16>(),
rng.gen::<u16>(),
rng.gen::<u64>() & 0xffffffffffff,
)
}
/// Split an URL into its base string and parameter map
///
/// Example:

View file

@ -45,6 +45,13 @@ impl ProtoBuilder {
self._varint(val);
}
/// Write a string field
pub fn string(&mut self, field: u32, string: &str) {
self._field(field, 2);
self._varint(string.len() as u64);
self.bytes.extend_from_slice(string.as_bytes());
}
/// Write an embedded message
///
/// Requires passing another [`ProtoBuilder`] with the embedded message.
@ -53,6 +60,12 @@ impl ProtoBuilder {
self._varint(pb.bytes.len() as u64);
self.bytes.append(&mut pb.bytes);
}
/// Base64 + urlencode the protobuf data
pub fn to_base64(&self) -> String {
let b64 = super::b64_encode(&self.bytes);
urlencoding::encode(&b64).to_string()
}
}
fn parse_varint<P: Iterator<Item = u8>>(pb: &mut P) -> Option<u64> {
@ -124,11 +137,6 @@ mod tests {
use super::*;
// #[test]
// fn t_parse_varint() {
// }
#[test]
fn t_parse_proto() {
let p = "GhhVQzl2cnZOU0wzeGNXR1NrVjg2UkVCU2c%3D";