Skip to content

Commit

Permalink
Fix 1stkissmanga get_chapter_list (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
DthRazak authored Oct 11, 2023
1 parent 071b7f7 commit 38e9680
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/rust/madara/sources/firstkissmanga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
aidoku = { git = "https://github.com/Aidoku/aidoku-rs/" }
aidoku = { git = "https://github.com/Aidoku/aidoku-rs/", features = ["helpers"] }
base64 = { version = "0.21.4", default-features = false, features = ["alloc"] }
madara_template = { path = "../../template" }
2 changes: 1 addition & 1 deletion src/rust/madara/sources/firstkissmanga/res/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "en.firstkissmanga",
"lang": "en",
"name": "1ST KISS MANGA",
"version": 2,
"version": 3,
"url": "https://1st-kissmanga.net",
"nsfw": 1
},
Expand Down
27 changes: 25 additions & 2 deletions src/rust/madara/sources/firstkissmanga/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#![no_std]
use aidoku::{
error::Result, prelude::*, std::net::Request, std::String, std::Vec, Chapter, DeepLink, Filter,
Listing, Manga, MangaPageResult, Page,
error::Result, prelude::*, std::net::Request, std::net::HttpMethod, std::String, std::Vec,
Chapter, DeepLink, Filter, Listing, Manga, MangaPageResult, Page,
helpers::substring::Substring
};

use madara_template::template;

extern crate base64;
use base64::{Engine as _, engine::general_purpose};

fn get_data() -> template::MadaraSiteData {
let data: template::MadaraSiteData = template::MadaraSiteData {
base_url: String::from("https://1st-kissmanga.net"),
get_manga_id: get_int_manga_id,
alt_ajax: true,
..Default::default()
};
Expand Down Expand Up @@ -49,3 +54,21 @@ pub fn handle_url(url: String) -> Result<DeepLink> {
fn modify_image_request(request: Request) {
template::modify_image_request(get_data().base_url, request)
}

fn get_int_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() {
// For this web page, the script is encoded in base64
let id_html_encoded = html.select("script#wp-manga-js-extra").attr("src").read();
let id_html_base64 = id_html_encoded
.substring_after("data:text/javascript;base64,").unwrap_or_default();
let id_html_decoded = general_purpose::STANDARD.decode(id_html_base64).unwrap();
let id_html = String::from_utf8(id_html_decoded).unwrap_or_default();

let id = &id_html[id_html.find("manga_id").expect("Could not find manga_id") + 11
..id_html.find("\"}").expect("Could not find end of manga_id")];
String::from(id)
} else {
String::new()
}
}

0 comments on commit 38e9680

Please sign in to comment.