Fix disowned gallery uploader parsing (#918)

* Fix disowned gallery uploader parsing

* Run rustfmt

* Refine

* Run rustfmt
This commit is contained in:
FooIbar authored and GitHub committed 2024-03-16 17:48:10 +08:00
1 parent a114a8ac72
commit 8f8db82e9d
1 file changed
+10 -3
+10 -3
View File
@@ -96,9 +96,16 @@ fn parse_token_and_gid(str: &str) -> Option<(i64, String)> {
}
fn parse_uploader_and_pages(str: &str) -> (Option<String>, bool, i32) {
let uploader = regex!(r#"<a href="https://e[x-]hentai.org/uploader/.*?">(.*?)</a>"#)
.captures(str)
.map(|grp| grp[1].to_string());
let uploader =
regex!(r#"<a href="https://e[x-]hentai.org/uploader/.*?">(.*?)</a>|(\(Disowned\))"#)
.captures(str)
.map(|grp| {
grp.get(1)
.or_else(|| grp.get(2))
.unwrap()
.as_str()
.to_string()
});
let pages = match regex!(r"<div>(\d+) pages</div>").captures(str) {
None => 0,
Some(grp) => grp[1].parse().unwrap_or(0),