Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Sushi Scan #413

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rust/mangastream/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["template", "sources/*"]
resolver = "2"

[profile.dev]
panic = "abort"
Expand Down
15 changes: 14 additions & 1 deletion src/rust/mangastream/sources/sushiscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ use mangastream_template::template::MangaStreamSource;
fn get_instance() -> MangaStreamSource {
MangaStreamSource {
base_url: String::from("https://sushiscan.net"),
traverse_pathname: "catalogue",
listing: ["Dernières", "Populaire", "Nouveau"],
status_options: ["En Cours", "Terminé", "", "", ""],
manga_details_author: ".imptdt:contains(Auteur) i, .fmed b:contains(Auteur)+span",
language: "fr",
locale: "fr-FR",
..Default::default()
}
}
Expand All @@ -36,7 +41,15 @@ fn get_chapter_list(id: String) -> Result<Vec<Chapter>> {

#[get_page_list]
fn get_page_list(_manga_id: String, id: String) -> Result<Vec<Page>> {
get_instance().parse_page_list(id)
let pages = get_instance().parse_page_list(id)?;
// fix http -> https
let mut new_pages = Vec::new();
for page in pages {
let mut new_page = page;
new_page.url = new_page.url.replace("http://", "https://");
new_pages.push(new_page);
}
Ok(new_pages)
}

#[modify_image_request]
Expand Down
20 changes: 13 additions & 7 deletions src/rust/mangastream/template/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,22 @@ pub fn manga_status(
status_options: [&'static str; 5],
status_options_2: [&'static str; 5],
) -> MangaStatus {
if status.contains(status_options[0]) || status.contains(status_options_2[0]) {
if (!status_options[0].is_empty() && status.contains(status_options[0]))
|| (!status_options_2[0].is_empty() && status.contains(status_options_2[0]))
{
MangaStatus::Ongoing
} else if status.contains(status_options[1]) || status.contains(status_options_2[1]) {
} else if (!status_options[1].is_empty() && status.contains(status_options[1]))
|| (!status_options_2[1].is_empty() && status.contains(status_options_2[1]))
{
MangaStatus::Completed
} else if status.contains(status_options[2]) || status.contains(status_options_2[2]) {
} else if (!status_options[2].is_empty() && status.contains(status_options[2]))
|| (!status_options_2[2].is_empty() && status.contains(status_options_2[2]))
{
MangaStatus::Hiatus
} else if status.contains(status_options[3])
|| status.contains(status_options[4])
|| status.contains(status_options_2[3])
|| status.contains(status_options_2[4])
} else if (!status_options[3].is_empty() && status.contains(status_options[3]))
|| (!status_options[4].is_empty() && status.contains(status_options[4]))
|| (!status_options_2[3].is_empty() && status.contains(status_options_2[3]))
|| (!status_options_2[4].is_empty() && status.contains(status_options_2[4]))
{
MangaStatus::Cancelled
} else {
Expand Down
29 changes: 8 additions & 21 deletions src/rust/mangastream/template/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use aidoku::{
std::json::parse,
std::net::{HttpMethod, Request},
std::{String, Vec},
Chapter, DeepLink, Filter, FilterType, Manga, MangaContentRating, MangaPageResult, MangaStatus,
MangaViewer, Page,
Chapter, DeepLink, Filter, FilterType, Manga, MangaContentRating, MangaPageResult, MangaViewer,
Page,
};

use crate::helper::*;
Expand Down Expand Up @@ -77,7 +77,7 @@ impl Default for MangaStreamSource {
manga_title_trim: ["light novel".into()].to_vec(),
last_page_text: "Next",
last_page_text_2: "NNNN",
status_options: [ "Ongoing", "Completed", "Hiatus", "Cancelled", "Dropped" ],
status_options: ["Ongoing", "Completed", "Hiatus", "Cancelled", "Dropped"],
status_options_2: ["","","","",""],

manga_details_categories: "span.mgen a",
Expand Down Expand Up @@ -213,14 +213,8 @@ impl MangaStreamSource {
id,
cover,
title,
author: String::new(),
artist: String::new(),
description: String::new(),
url,
categories: Vec::new(),
status: MangaStatus::Unknown,
nsfw: MangaContentRating::Safe,
viewer: MangaViewer::Rtl,
..Default::default()
});
}
let last_page_string = if !html.select(self.next_page).text().read().is_empty() {
Expand Down Expand Up @@ -352,12 +346,11 @@ impl MangaStreamSource {
chapters.push(Chapter {
id: chapter_id,
title,
volume: -1.0,
chapter: chapter_number,
date_updated,
scanlator: String::new(),
url: chapter_url,
lang: String::from(self.language),
..Default::default()
});
}
Ok(chapters)
Expand Down Expand Up @@ -404,20 +397,15 @@ impl MangaStreamSource {
pages.push(Page {
index: index as i32,
url: page_url,
base64: String::new(),
text: String::new(),
..Default::default()
});
}
Ok(pages)
} else {
for (at, page) in html.select(self.page_selector).array().enumerate() {
let page_node = page.as_node().expect("Failed to get page as node");
let page_url = if self.protocol {
format!(
"{}{}",
"https:",
urlencode(page_node.attr(self.page_url).read())
)
format!("https:{}", urlencode(page_node.attr(self.page_url).read()))
} else {
urlencode(page_node.attr(self.page_url).read())
};
Expand All @@ -428,8 +416,7 @@ impl MangaStreamSource {
pages.push(Page {
index: at as i32,
url: page_url,
base64: String::new(),
text: String::new(),
..Default::default()
});
}
Ok(pages)
Expand Down
Loading