diff --git a/src/rust/mangastream/Cargo.toml b/src/rust/mangastream/Cargo.toml index f9f3dc4b8..fdba8a30a 100644 --- a/src/rust/mangastream/Cargo.toml +++ b/src/rust/mangastream/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["template", "sources/*"] +resolver = "2" [profile.dev] panic = "abort" diff --git a/src/rust/mangastream/sources/sushiscan/src/lib.rs b/src/rust/mangastream/sources/sushiscan/src/lib.rs index 4494afe54..9821a00c8 100644 --- a/src/rust/mangastream/sources/sushiscan/src/lib.rs +++ b/src/rust/mangastream/sources/sushiscan/src/lib.rs @@ -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() } } @@ -36,7 +41,15 @@ fn get_chapter_list(id: String) -> Result> { #[get_page_list] fn get_page_list(_manga_id: String, id: String) -> Result> { - 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] diff --git a/src/rust/mangastream/template/src/helper.rs b/src/rust/mangastream/template/src/helper.rs index 9ebf96cf5..2b9583dd6 100644 --- a/src/rust/mangastream/template/src/helper.rs +++ b/src/rust/mangastream/template/src/helper.rs @@ -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 { diff --git a/src/rust/mangastream/template/src/template.rs b/src/rust/mangastream/template/src/template.rs index fb688653e..5b843c42c 100644 --- a/src/rust/mangastream/template/src/template.rs +++ b/src/rust/mangastream/template/src/template.rs @@ -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::*; @@ -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", @@ -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() { @@ -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) @@ -404,8 +397,7 @@ impl MangaStreamSource { pages.push(Page { index: index as i32, url: page_url, - base64: String::new(), - text: String::new(), + ..Default::default() }); } Ok(pages) @@ -413,11 +405,7 @@ impl MangaStreamSource { 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()) }; @@ -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)