From 3521ccacbf1e83a6eb391babc2d104235dc19f06 Mon Sep 17 00:00:00 2001 From: KaBanks <20971850+KaBankz@users.noreply.github.com> Date: Tue, 29 Aug 2023 20:35:33 -0400 Subject: [PATCH] fix(setsuscans): remove get_manga_id override (#432) * fix(setsuscans): remove get_manga_id override * chore(madara): fix formatting --- src/rust/madara/Cargo.lock | 7 ----- src/rust/madara/sources/setsuscans/Cargo.toml | 1 - .../madara/sources/setsuscans/res/source.json | 2 +- src/rust/madara/sources/setsuscans/src/lib.rs | 29 ++----------------- src/rust/madara/sources/shinigami/src/lib.rs | 4 +-- 5 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/rust/madara/Cargo.lock b/src/rust/madara/Cargo.lock index 9f9700e09..eaead9f5e 100644 --- a/src/rust/madara/Cargo.lock +++ b/src/rust/madara/Cargo.lock @@ -57,12 +57,6 @@ dependencies = [ "madara_template", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "coloredmanga" version = "0.1.0" @@ -308,7 +302,6 @@ name = "setsuscans" version = "0.1.0" dependencies = [ "aidoku", - "base64", "madara_template", ] diff --git a/src/rust/madara/sources/setsuscans/Cargo.toml b/src/rust/madara/sources/setsuscans/Cargo.toml index b1b619787..d558da17e 100644 --- a/src/rust/madara/sources/setsuscans/Cargo.toml +++ b/src/rust/madara/sources/setsuscans/Cargo.toml @@ -10,4 +10,3 @@ crate-type = ["cdylib"] [dependencies] aidoku = { git = "https://github.com/Aidoku/aidoku-rs/" } madara_template = { path = "../../template" } -base64 = { version = "0.13.1", default-features = false, features = ["alloc"] } diff --git a/src/rust/madara/sources/setsuscans/res/source.json b/src/rust/madara/sources/setsuscans/res/source.json index 66754ab58..8b36ba9b9 100644 --- a/src/rust/madara/sources/setsuscans/res/source.json +++ b/src/rust/madara/sources/setsuscans/res/source.json @@ -3,7 +3,7 @@ "id": "en.setsuscans", "lang": "en", "name": "Setsu Scans", - "version": 3, + "version": 4, "url": "https://setsuscans.com", "nsfw": 1 }, diff --git a/src/rust/madara/sources/setsuscans/src/lib.rs b/src/rust/madara/sources/setsuscans/src/lib.rs index 4fb087180..696ba4eb0 100644 --- a/src/rust/madara/sources/setsuscans/src/lib.rs +++ b/src/rust/madara/sources/setsuscans/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] use aidoku::{ - error::Result, prelude::*, std::net::HttpMethod, std::net::Request, std::String, std::Vec, - Chapter, DeepLink, Filter, Listing, Manga, MangaPageResult, Page, + error::Result, prelude::*, std::String, std::Vec, Chapter, DeepLink, Filter, Listing, Manga, + MangaPageResult, Page, }; use madara_template::template; @@ -10,37 +10,12 @@ fn get_data() -> template::MadaraSiteData { let data: template::MadaraSiteData = template::MadaraSiteData { base_url: String::from("https://setsuscans.com"), description_selector: String::from("div.summary_content_wrap div p"), - get_manga_id, alt_ajax: true, ..Default::default() }; data } -// SetsuScans keeps its manga data in its src attribute as a base64 encoded -// string so this function overrides the default get_manga_id function to handle -// SetsuScans -fn get_manga_id(manga_id: String, base_url: String, path: String) -> String { - let url = base_url + "/" + path.as_str() + "/" + manga_id.as_str(); - if let Ok(html) = Request::new(url.as_str(), HttpMethod::Get).html() { - let id_html = html.select("script#wp-manga-js-extra").attr("src").read(); - let id_html = id_html.replace("data:text/javascript;base64,", ""); - let decoded_html = base64::decode(id_html).expect("Failed to decode base64"); - let decoded_html = - String::from_utf8(decoded_html).expect("Failed to convert base64 to utf8"); - let id = &decoded_html[decoded_html - .find("manga_id") - .expect("Failed to find manga_id") - + 11 - ..decoded_html - .find("\"}") - .expect("Failed to find end of manga_id")]; - String::from(id) - } else { - String::new() - } -} - #[get_manga_list] fn get_manga_list(filters: Vec, page: i32) -> Result { template::get_manga_list(filters, page, get_data()) diff --git a/src/rust/madara/sources/shinigami/src/lib.rs b/src/rust/madara/sources/shinigami/src/lib.rs index 4b7016ea4..31f8e407f 100644 --- a/src/rust/madara/sources/shinigami/src/lib.rs +++ b/src/rust/madara/sources/shinigami/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] use aidoku::{ - error::Result, prelude::*, std::String, std::Vec, - Chapter, DeepLink, Filter, Listing, Manga, MangaPageResult, Page, + error::Result, prelude::*, std::String, std::Vec, Chapter, DeepLink, Filter, Listing, Manga, + MangaPageResult, Page, }; use madara_template::template;