Skip to content

Commit

Permalink
fix(setsuscans): remove get_manga_id override (#432)
Browse files Browse the repository at this point in the history
* fix(setsuscans): remove get_manga_id override

* chore(madara): fix formatting
  • Loading branch information
KaBankz authored Aug 30, 2023
1 parent 8256c76 commit 3521cca
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 38 deletions.
7 changes: 0 additions & 7 deletions src/rust/madara/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/rust/madara/sources/setsuscans/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion src/rust/madara/sources/setsuscans/res/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "en.setsuscans",
"lang": "en",
"name": "Setsu Scans",
"version": 3,
"version": 4,
"url": "https://setsuscans.com",
"nsfw": 1
},
Expand Down
29 changes: 2 additions & 27 deletions src/rust/madara/sources/setsuscans/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Filter>, page: i32) -> Result<MangaPageResult> {
template::get_manga_list(filters, page, get_data())
Expand Down
4 changes: 2 additions & 2 deletions src/rust/madara/sources/shinigami/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 3521cca

Please sign in to comment.