Skip to content

Commit

Permalink
fix(manhuagui): incorrect chapter order
Browse files Browse the repository at this point in the history
  • Loading branch information
dyphire committed Oct 21, 2024
1 parent e585608 commit 7e07c35
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/rust/zh.manhuagui/res/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
7 changes: 3 additions & 4 deletions src/rust/zh.manhuagui/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -69,7 +68,7 @@ impl Decoder {
let mut d_value: Vec<String> = 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
Expand Down
7 changes: 4 additions & 3 deletions src/rust/zh.manhuagui/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn get_chapter_list(html: Node) -> Result<Vec<Chapter>> {
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,
Expand All @@ -224,7 +224,7 @@ pub fn get_chapter_list(html: Node) -> Result<Vec<Chapter>> {
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,
Expand All @@ -239,7 +239,7 @@ pub fn get_chapter_list(html: Node) -> Result<Vec<Chapter>> {
let title = elem.select("a").attr("title").read();
let chapter_or_volume = title
.clone()
.replace(['第', '话', '卷'], "")
.replace(['第', '话', '話', '回', '卷'], " ")
.parse::<f32>()
.unwrap_or(index);
let ch = if title.contains('卷') {
Expand Down Expand Up @@ -270,6 +270,7 @@ pub fn get_chapter_list(html: Node) -> Result<Vec<Chapter>> {
}
}

chapters.reverse();
Ok(chapters)
}

Expand Down

0 comments on commit 7e07c35

Please sign in to comment.