From 5b8c7f432df8fe76ceb3e74a0a613c0431489fdd Mon Sep 17 00:00:00 2001 From: dyphire <61936050+dyphire@users.noreply.github.com> Date: Sat, 9 Nov 2024 03:13:22 +0800 Subject: [PATCH] fix(manhuagui): incorrect chapter order (#785) --- src/rust/zh.manhuagui/res/source.json | 4 ++-- src/rust/zh.manhuagui/src/decoder.rs | 7 +++---- src/rust/zh.manhuagui/src/parser.rs | 7 ++++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/rust/zh.manhuagui/res/source.json b/src/rust/zh.manhuagui/res/source.json index ba45377b3..a813cac39 100644 --- a/src/rust/zh.manhuagui/res/source.json +++ b/src/rust/zh.manhuagui/res/source.json @@ -3,8 +3,8 @@ "id": "zh.manhuagui", "lang": "zh", "name": "ManHuaGui", - "version": 2, - "url": "https://www.manhuagui.com/", + "version": 3, + "url": "https://www.manhuagui.com", "nsfw": 1 } } diff --git a/src/rust/zh.manhuagui/src/decoder.rs b/src/rust/zh.manhuagui/src/decoder.rs index 0d4629eb0..f886d45a4 100644 --- a/src/rust/zh.manhuagui/src/decoder.rs +++ b/src/rust/zh.manhuagui/src/decoder.rs @@ -36,8 +36,7 @@ impl Decoder { String::new() }; - let suffix_vec = vec![ - self.tr(c % self.a, 36), + let suffix_vec = [self.tr(c % self.a, 36), String::from_utf8(vec![(c % self.a + 29) as u8]).unwrap_or_default(), ]; let suffix = suffix_vec[(c % self.a > 35) as usize].clone(); @@ -47,7 +46,7 @@ impl Decoder { fn tr(&self, value: i32, num: i32) -> String { let tmp = Self::itr(value, num); - if tmp.eq("") { + if tmp.is_empty() { return String::from("0"); } tmp @@ -69,7 +68,7 @@ impl Decoder { let mut d_value: Vec = vec![]; while c > -1 { let key = self.e(c); - let value_index = self.data[c as usize].eq("") as usize; + let value_index = self.data[c as usize].is_empty() as usize; let value = vec![self.data[c as usize].clone(), self.e(c)][value_index].clone(); let index = d_key diff --git a/src/rust/zh.manhuagui/src/parser.rs b/src/rust/zh.manhuagui/src/parser.rs index 55699a7fa..63668c876 100644 --- a/src/rust/zh.manhuagui/src/parser.rs +++ b/src/rust/zh.manhuagui/src/parser.rs @@ -212,7 +212,7 @@ pub fn get_chapter_list(html: Node) -> Result> { div = Node::new_fragment(decompressed.as_bytes()).unwrap_or(div); } - for element in div.select(".chapter-list").array() { + for element in div.select(".chapter-list").array().rev() { let chapt_list_div = match element.as_node() { Ok(node) => node, Err(_) => continue, @@ -224,7 +224,7 @@ pub fn get_chapter_list(html: Node) -> Result> { Err(_) => continue, }; - for li_ref in ul.select("li").array() { + for li_ref in ul.select("li").array().rev() { let elem = match li_ref.as_node() { Ok(node) => node, Err(_) => continue, @@ -239,7 +239,7 @@ pub fn get_chapter_list(html: Node) -> Result> { let title = elem.select("a").attr("title").read(); let chapter_or_volume = title .clone() - .replace(['第', '话', '卷'], "") + .replace(['第', '话', '話', '回', '卷'], " ") .parse::() .unwrap_or(index); let ch = if title.contains('卷') { @@ -269,6 +269,7 @@ pub fn get_chapter_list(html: Node) -> Result> { } } } + chapters.reverse(); Ok(chapters) }