Crates.io | clearurl |
lib.rs | clearurl |
version | 0.7.1 |
source | src |
created_at | 2022-02-18 15:12:42.677624 |
updated_at | 2024-02-14 01:49:59.900388 |
description | A rust implementation for ClearURL |
homepage | |
repository | https://github.com/Avimitin/clearurl |
max_upload_size | |
id | 534745 |
size | 24,366 |
This is a Rust implementation of the ClearURL lib.
# Cargo.toml
clearurl = { version = "0.6", features = ["hooks"] }
use clearurl::URLCleaner;
#[tokio::main]
async fn main() {
std::fs::write("rules.toml", r#"
["b23.tv"]
redirect = true
["bilibili.com"]
sub = ["www", "live", "m"]
ban = [
"-Arouter",
"bbid",
"buvid",
"callback",
"from.*",
"is_story_h5",
"mid",
"msource",
"plat_id",
"refer_from",
"seid",
"share.*",
"spm_id.*",
"timestamp",
"ts",
"unique_k",
"up_id",
"vd_source",
]
post_hooks = [ "bv_to_av" ]
"#).unwrap();
let cleaner = URLCleaner::from_file("./rules.toml").unwrap();
let url = cleaner.clear("https://b23.tv/Cj2HC2K").await.unwrap();
assert_eq!(
url.as_str(),
"https://www.bilibili.com/video/av746592874/?p=1"
);
}