mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
remove /jump.php track links
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -1075,6 +1075,7 @@ dependencies = [
|
||||
"reqwest",
|
||||
"spin_on",
|
||||
"tokio",
|
||||
"urlparse",
|
||||
"utf16string",
|
||||
"winapi",
|
||||
]
|
||||
@@ -1702,6 +1703,12 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlparse"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "110352d4e9076c67839003c7788d8604e24dcded13e0b375af3efaa8cf468517"
|
||||
|
||||
[[package]]
|
||||
name = "utf16string"
|
||||
version = "0.2.0"
|
||||
|
||||
@@ -16,12 +16,13 @@ html_parser = "0.6.2"
|
||||
int-enum = { version = "0.4", optional = true }
|
||||
lazy_static = "1.4"
|
||||
json = "0.12"
|
||||
utf16string = { version= "0.2", optional = true }
|
||||
regex = "1"
|
||||
reqwest = { version = "0.11", features = ["brotli", "deflate", "gzip", "rustls-tls", "socks", "stream"] }
|
||||
RustyXML = "0.3"
|
||||
spin_on = "0.1.1"
|
||||
tokio = { version = "1.17", features = ["rt", "macros", "rt-multi-thread", "time"] }
|
||||
urlparse = "0.7"
|
||||
utf16string = { version= "0.2", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
cmake = "0.1"
|
||||
|
||||
@@ -11,6 +11,7 @@ extern crate lazy_static;
|
||||
extern crate tokio;
|
||||
extern crate regex;
|
||||
extern crate reqwest;
|
||||
extern crate urlparse;
|
||||
#[cfg(feature = "utf16string")]
|
||||
extern crate utf16string;
|
||||
extern crate xml;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::gettext;
|
||||
use crate::pixiv_link::remove_track;
|
||||
use html_parser::Dom;
|
||||
use html_parser::Node;
|
||||
use std::collections::HashMap;
|
||||
@@ -98,7 +99,8 @@ impl DescriptionParser {
|
||||
if href.is_some() {
|
||||
let href = href.unwrap();
|
||||
if href.is_some() {
|
||||
node.add_attr("href", href.as_ref().unwrap());
|
||||
let link = remove_track(href.as_ref().unwrap());
|
||||
node.add_attr("href", link.as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,4 +173,8 @@ fn test_parse_description() {
|
||||
Some(String::from("a [a\n[bc](a.com)d](b.com)\ndata")),
|
||||
parse_description("a <a href=\"b.com\">a<br/><a href=\"a.com\">bc</a>d</a><br>data")
|
||||
);
|
||||
assert_eq!(
|
||||
Some(String::from("https://a.com")),
|
||||
parse_description("<a href=\"/jump.php?https%3A%2F%2Fa.com\">https://a.com</a>")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::data::json::ToJson;
|
||||
use json::JsonValue;
|
||||
use regex::Regex;
|
||||
use reqwest::IntoUrl;
|
||||
use std::convert::TryInto;
|
||||
|
||||
lazy_static! {
|
||||
@@ -98,3 +99,19 @@ impl TryInto<u64> for &PixivID {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_track<U: IntoUrl>(url: U) -> String {
|
||||
let s = String::from(url.as_str());
|
||||
let u = urlparse::urlparse(s.as_str());
|
||||
let path = u.path.as_str();
|
||||
if path.ends_with("/jump.php") {
|
||||
if u.query.is_some() {
|
||||
let q = u.query.as_ref().unwrap();
|
||||
let re = urlparse::unquote(q);
|
||||
if re.is_ok() {
|
||||
return re.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user