Author name filters now support look around and backreferences

This commit is contained in:
2022-06-21 05:57:27 +00:00
committed by GitHub
parent adc650f8c6
commit 6903a1fe8d
9 changed files with 40 additions and 10 deletions

27
Cargo.lock generated
View File

@@ -104,6 +104,21 @@ dependencies = [
"which",
]
[[package]]
name = "bit-set"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -453,6 +468,16 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "fancy-regex"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0678ab2d46fa5195aaf59ad034c083d351377d4af57f3e073c074d0da3e3c766"
dependencies = [
"bit-set",
"regex",
]
[[package]]
name = "fastrand"
version = "1.7.0"
@@ -1237,6 +1262,7 @@ dependencies = [
"cmake",
"dateparser",
"derive_more",
"fancy-regex",
"flagset",
"futures-util",
"getopts",
@@ -1253,7 +1279,6 @@ dependencies = [
"modular-bitfield",
"parse-size",
"proc_macros",
"regex",
"reqwest",
"tokio",
"url",

View File

@@ -11,6 +11,7 @@ c_fixed_string = { version = "0.2", optional = true }
chrono = "0.4"
dateparser = "0.1.6"
derive_more = "0.99"
fancy-regex = "0.10"
flagset = { version = "0.4", optional = true }
futures-util = "0.3"
getopts = "0.2"
@@ -26,7 +27,6 @@ lazy_static = "1.4"
modular-bitfield = "0.11"
parse-size = "1"
proc_macros = { path = "proc_macros" }
regex = "1"
reqwest = { version = "0.11", features = ["brotli", "deflate", "gzip", "rustls-tls", "socks", "stream"] }
RustyXML = "0.3"
tokio = { version = "1.19", features = ["rt", "macros", "rt-multi-thread", "time"] }

View File

@@ -1,5 +1,5 @@
use crate::author_name_filter::AuthorFiler;
use crate::gettext;
use crate::opt::author_name_filter::AuthorFiler;
use crate::opthelper::get_helper;
use crate::pixiv_link::PixivID;
use crate::pixiv_link::ToPixivID;

View File

@@ -9,7 +9,6 @@ mod _avdict;
mod _exif;
#[cfg(feature = "ugoira")]
mod _ugoira;
mod author_name_filter;
#[cfg(feature = "avdict")]
/// A rust wrapper for [FFMPEG](https://ffmpeg.org/)'s [AVDictionary](https://ffmpeg.org/doxygen/trunk/group__lavu__dict.html)
mod avdict;

View File

@@ -1,17 +1,17 @@
use crate::ext::json::ToJson;
use crate::ext::try_err::TryErr;
use crate::gettext;
use fancy_regex::Regex;
use json::JsonValue;
use regex::Regex;
use std::cmp::PartialEq;
use std::convert::From;
use std::convert::TryFrom;
use std::fmt::Display;
#[derive(Debug, derive_more::From, PartialEq)]
#[derive(Debug, derive_more::From)]
pub enum AuthorNameFilterError {
String(String),
Regex(regex::Error),
Regex(fancy_regex::Error),
}
impl Display for AuthorNameFilterError {

View File

@@ -1,3 +1,5 @@
/// Author name filters
pub mod author_name_filter;
/// Proxy settings
pub mod proxy;
pub mod size;

View File

@@ -1,10 +1,10 @@
use crate::author_name_filter::AuthorNameFilter;
use crate::ext::json::FromJson;
use crate::ext::replace::ReplaceWith2;
use crate::ext::rw_lock::GetRwLock;
use crate::ext::use_or_not::ToBool;
use crate::ext::use_or_not::UseOrNot;
use crate::list::NonTailList;
use crate::opt::author_name_filter::AuthorNameFilter;
use crate::opt::proxy::ProxyChain;
use crate::opt::size::parse_u32_size;
use crate::opt::use_progress_bar::UseProgressBar;

View File

@@ -1,6 +1,6 @@
use crate::ext::json::ToJson;
use fancy_regex::Regex;
use json::JsonValue;
use regex::Regex;
use reqwest::IntoUrl;
use std::convert::TryInto;
@@ -28,6 +28,10 @@ impl PixivID {
return Some(PixivID::Artwork(num.unwrap()));
}
let re = RE.captures(s);
if re.is_err() {
return None;
}
let re = re.unwrap();
if re.is_some() {
let r = re.unwrap().name("id");
if r.is_some() {

View File

@@ -1,10 +1,10 @@
use crate::author_name_filter::check_author_name_filters;
use crate::ext::json::FromJson;
use crate::ext::use_or_not::UseOrNot;
use crate::gettext;
use crate::retry_interval::check_retry_interval;
use crate::settings::SettingDes;
use crate::settings::JsonValueType;
use crate::opt::author_name_filter::check_author_name_filters;
use crate::opt::proxy::check_proxy;
use crate::opt::size::parse_u32_size;
use json::JsonValue;