feat!: generate random visitorData, remove RustyPipeQuery::get_context and YTContext<'a> from public API
This commit is contained in:
parent
9e835c8f38
commit
7c4f44d09c
22 changed files with 99 additions and 258 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Reference in a new issue