chore: update base64 and fancy-regex
This commit is contained in:
parent
a706a7011b
commit
d8889ed5d4
5 changed files with 17 additions and 6 deletions
|
|
@ -26,7 +26,7 @@ rustls-tls-native-roots = ["reqwest/rustls-tls-native-roots"]
|
|||
# quick-js = "0.4.1"
|
||||
quick-js = { path = "../quickjs-rs", default-features = false }
|
||||
once_cell = "1.12.0"
|
||||
fancy-regex = "0.10.0"
|
||||
fancy-regex = "0.11.0"
|
||||
thiserror = "1.0.36"
|
||||
url = "2.2.2"
|
||||
log = "0.4.17"
|
||||
|
|
@ -48,7 +48,7 @@ time = { version = "0.3.15", features = [
|
|||
futures = "0.3.21"
|
||||
ress = "0.11.4"
|
||||
phf = "0.11.1"
|
||||
base64 = "0.20.0"
|
||||
base64 = "0.21.0"
|
||||
urlencoding = "2.1.2"
|
||||
quick-xml = { version = "0.26.0", features = ["serialize"], optional = true }
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ fn map_artist_page(
|
|||
|
||||
let share_channel_id = urlencoding::decode(&pb)
|
||||
.ok()
|
||||
.and_then(|pb| base64::decode(pb.as_bytes()).ok())
|
||||
.and_then(|pb| util::b64_decode(pb.as_bytes()).ok())
|
||||
.and_then(|pb| util::string_from_pb(pb, 3));
|
||||
|
||||
if let Some(share_channel_id) = share_channel_id {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use crate::util::ProtoBuilder;
|
||||
use crate::util::{self, ProtoBuilder};
|
||||
|
||||
/// YouTube search filter
|
||||
///
|
||||
|
|
@ -200,7 +200,7 @@ impl SearchFilter {
|
|||
pb.embedded(8, extras)
|
||||
}
|
||||
|
||||
let b64 = base64::encode(pb.bytes);
|
||||
let b64 = util::b64_encode(pb.bytes);
|
||||
urlencoding::encode(&b64).to_string()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use std::{
|
|||
str::FromStr,
|
||||
};
|
||||
|
||||
use base64::Engine;
|
||||
use fancy_regex::Regex;
|
||||
use once_cell::sync::Lazy;
|
||||
use rand::Rng;
|
||||
|
|
@ -343,6 +344,14 @@ pub fn video_id_from_thumbnail_url(url: &str) -> Option<String> {
|
|||
.and_then(|cap| cap.get(1).map(|x| x.as_str().to_owned()))
|
||||
}
|
||||
|
||||
pub fn b64_encode<T: AsRef<[u8]>>(input: T) -> String {
|
||||
base64::engine::general_purpose::STANDARD.encode(input)
|
||||
}
|
||||
|
||||
pub fn b64_decode<T: AsRef<[u8]>>(input: T) -> Result<Vec<u8>, base64::DecodeError> {
|
||||
base64::engine::general_purpose::STANDARD.decode(input)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{fs::File, io::BufReader};
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ pub fn string_from_pb<P: IntoIterator<Item = u8>>(pb: P, field: u32) -> Option<S
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::util;
|
||||
|
||||
use super::*;
|
||||
|
||||
// #[test]
|
||||
|
|
@ -130,7 +132,7 @@ mod tests {
|
|||
#[test]
|
||||
fn t_parse_proto() {
|
||||
let p = "GhhVQzl2cnZOU0wzeGNXR1NrVjg2UkVCU2c%3D";
|
||||
let p_bytes = base64::decode(urlencoding::decode(p).unwrap().as_bytes()).unwrap();
|
||||
let p_bytes = util::b64_decode(urlencoding::decode(p).unwrap().as_bytes()).unwrap();
|
||||
|
||||
let res = string_from_pb(p_bytes, 3).unwrap();
|
||||
assert_eq!(res, "UC9vrvNSL3xcWGSkV86REBSg");
|
||||
|
|
|
|||
Reference in a new issue