feat!: generate random visitorData, remove RustyPipeQuery::get_context and YTContext<'a> from public API

This commit is contained in:
ThetaDev 2024-10-23 01:51:16 +02:00
parent 9e835c8f38
commit 7c4f44d09c
No known key found for this signature in database
GPG key ID: E319D3C5148D65B6
22 changed files with 99 additions and 258 deletions

View file

@ -94,6 +94,29 @@ pub fn random_uuid() -> String {
)
}
/// Generate a random visitor data cookie
pub fn random_visitor_data(country: Country) -> String {
let mut rng = rand::thread_rng();
let mut pb_e2 = ProtoBuilder::new();
pb_e2.string(2, "");
pb_e2.varint(4, rng.gen_range(1..256));
let mut pb_e = ProtoBuilder::new();
pb_e.string(1, &country.to_string());
pb_e.embedded(2, pb_e2);
let mut pb = ProtoBuilder::new();
pb.string(1, &random_string(CONTENT_PLAYBACK_NONCE_ALPHABET, 11));
pb.varint(
5,
(time::OffsetDateTime::now_utc().unix_timestamp() as u64)
.saturating_sub(rng.gen_range(0..600_000)),
);
pb.embedded(6, pb_e);
pb.to_base64()
}
/// Split an URL into its base string and parameter map
///
/// Example: