Skip to content
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
7 changes: 0 additions & 7 deletions sources/en.comix/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 sources/en.comix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ crate-type = ["cdylib"]

[dependencies]
aidoku = { git = "https://github.com/Aidoku/aidoku-rs.git", features = ["json"] }
base64 = { version = "0.22", default-features = false, features = ["alloc"] }
serde = { version = "1.0", features = ["derive", "alloc"], default-features = false }
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }

Expand Down
2 changes: 1 addition & 1 deletion sources/en.comix/res/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"info": {
"id": "en.comix",
"name": "Comix",
"version": 9,
"version": 10,
"url": "https://comix.to",
"contentRating": 1,
"languages": ["en"]
Expand Down
230 changes: 0 additions & 230 deletions sources/en.comix/src/hash.rs

This file was deleted.

41 changes: 33 additions & 8 deletions sources/en.comix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
use aidoku::{
Chapter, DeepLinkHandler, DeepLinkResult, FilterValue, HashMap, Home, HomeComponent,
HomeLayout, HomePartialResult, ImageRequestProvider, Link, LinkValue, Listing, ListingProvider,
Manga, MangaPageResult, MangaWithChapter, NotificationHandler, Page, Result, Source,
Manga, MangaPageResult, MangaWithChapter, NotificationHandler, Page, PageContent, Result,
Source,
alloc::{String, Vec, string::ToString, vec},
helpers::uri::{QueryParameters, encode_uri_component},
imports::{
Expand All @@ -12,10 +13,10 @@ use aidoku::{
prelude::*,
};

mod hash;
mod helpers;
mod models;
mod settings;
mod web;

use models::*;

Expand Down Expand Up @@ -201,9 +202,12 @@ impl Source for Comix {
let deduplicate = settings::dedupchapter();
let mut chapter_map: HashMap<String, ComixChapter> = HashMap::new();
let mut chapter_list: Vec<ComixChapter> = Vec::new();

let web_view = web::create_web_view()?;
let path = format!("/manga/{}/chapters", manga.key);
let token = web::get_token(&web_view, &path)?;

loop {
let path = format!("/manga/{}/chapters", manga.key);
let token = hash::generate_hash(&path);
let url = format!(
"{API_URL}{path}\
?limit={limit}\
Expand All @@ -212,7 +216,9 @@ impl Source for Comix {
&_={token}"
);

let res = Request::get(url)?.json_owned::<ChapterDetailsResponse>()?;
let encoded_res = Request::get(&url)?.string()?;
let result = web::decode_response(&web_view, &url, &encoded_res)?;
let res = serde_json::from_str::<ChapterDetailsResponse>(&result)?;

let items = res.result.items;

Expand Down Expand Up @@ -258,16 +264,35 @@ impl Source for Comix {
}

fn get_page_list(&self, _manga: Manga, chapter: Chapter) -> Result<Vec<Page>> {
let web_view = web::create_web_view()?;
let path = format!("/chapters/{}", chapter.key);
let token = hash::generate_hash(&path);
let token = web::get_token(&web_view, &path)?;
let url = format!("{API_URL}{path}?_={token}");
let json: ChapterResponse = Request::get(url)?.json_owned()?;
let encoded_res = Request::get(&url)?.string()?;
let result = web::decode_response(&web_view, &url, &encoded_res)?;
let json: ChapterResponse = serde_json::from_str(&result)?;

let Some(result) = json.result else {
bail!("Missing chapter")
};

Ok(result.pages.into_iter().map(Into::into).collect())
let base_url = result.pages.base_url.trim_end_matches('/');
Ok(result
.pages
.items
.into_iter()
.map(|page| {
let url = if page.url.starts_with("http") {
page.url
} else {
format!("{base_url}/{}", page.url.trim_start_matches('/'))
};
Page {
content: PageContent::url(url),
..Default::default()
}
})
.collect())
}
}

Expand Down
20 changes: 9 additions & 11 deletions sources/en.comix/src/models.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{BASE_URL, helpers, settings};
use aidoku::{
Chapter, ContentRating, Manga, MangaPageResult, MangaStatus, Page, PageContent, Viewer,
Chapter, ContentRating, Manga, MangaPageResult, MangaStatus, Viewer,
alloc::{String, Vec, string::ToString, vec},
prelude::*,
};
Expand Down Expand Up @@ -268,7 +268,7 @@ impl ComixChapter {

#[derive(Deserialize)]
pub struct ComixChapterWithPages {
pub pages: Vec<ComixPage>,
pub pages: ComixPages,
}

#[derive(Deserialize)]
Expand All @@ -290,17 +290,15 @@ pub struct ScanlationGroup {
}

#[derive(Deserialize)]
pub struct ComixPage {
pub url: String,
#[serde(rename_all = "camelCase")]
pub struct ComixPages {
pub base_url: String,
pub items: Vec<ComixPage>,
}

impl From<ComixPage> for Page {
fn from(value: ComixPage) -> Self {
Page {
content: PageContent::url(value.url),
..Default::default()
}
}
#[derive(Deserialize)]
pub struct ComixPage {
pub url: String,
}

// deserialize a bool from a json bool, number, or string
Expand Down
Loading
Loading