New Source: es.manhwaweb#264
Conversation
There was a problem hiding this comment.
all the json files should use tabs for indentation and end with a single newline, for convention.
| /// This prevents spamming the server and getting IP banned. | ||
| pub fn request_with_limits(url: &str, method: &str) -> Result<Request> { | ||
| // Sleep for 1 second to respect rate limits. | ||
| sleep(1); |
There was a problem hiding this comment.
instead, could you use set_rate_limit? this sets a specific rate limit in a given period. for example, 1 request allowed every 2 seconds. for reference, the mangadex source uses this.
| // Sleep for 1 second to respect rate limits. | ||
| sleep(1); | ||
| match method { | ||
| "POST" => Request::post(url).map_err(|e| e.into()), |
There was a problem hiding this comment.
I think you can do this.
| "POST" => Request::post(url).map_err(|e| e.into()), | |
| "POST" => Request::post(url).map_err(Into::into), |
| [dev-dependencies] | ||
| aidoku = { git = "https://github.com/Aidoku/aidoku-rs.git", features = ["test"] } | ||
| aidoku-test = { git = "https://github.com/Aidoku/aidoku-rs.git" } | ||
|
|
| /// Helper function to map genre IDs to Spanish names. | ||
| fn get_genre_name(id: &str) -> String { | ||
| match id { | ||
| "3" => "Acción", "29" => "Aventura", "18" => "Comedia", "1" => "Drama", | ||
| "42" => "Recuentos de la vida", "2" => "Romance", "5" => "Venganza", "6" => "Harem", | ||
| "23" => "Fantasía", "31" => "Sobrenatural", "25" => "Tragedia", "43" => "Psicológico", | ||
| "32" => "Horror", "44" => "Thriller", "28" => "Historias cortas", "30" => "Ecchi", | ||
| "34" => "Gore", "37" => "Girls love", "27" => "Boys love", "45" => "Reencarnación", | ||
| "41" => "Sistema de niveles", "33" => "Ciencia ficción", "38" => "Apocalíptico", | ||
| "39" => "Artes marciales", "40" => "Superpoderes", "35" => "Cultivación (cultivo)", | ||
| "8" => "Milf", _ => "Desconocido", | ||
| }.to_string() | ||
| } |
There was a problem hiding this comment.
this should probably be moved into the helpers module.
| /// Helper function to map genre IDs to Spanish names. | |
| fn get_genre_name(id: &str) -> String { | |
| match id { | |
| "3" => "Acción", "29" => "Aventura", "18" => "Comedia", "1" => "Drama", | |
| "42" => "Recuentos de la vida", "2" => "Romance", "5" => "Venganza", "6" => "Harem", | |
| "23" => "Fantasía", "31" => "Sobrenatural", "25" => "Tragedia", "43" => "Psicológico", | |
| "32" => "Horror", "44" => "Thriller", "28" => "Historias cortas", "30" => "Ecchi", | |
| "34" => "Gore", "37" => "Girls love", "27" => "Boys love", "45" => "Reencarnación", | |
| "41" => "Sistema de niveles", "33" => "Ciencia ficción", "38" => "Apocalíptico", | |
| "39" => "Artes marciales", "40" => "Superpoderes", "35" => "Cultivación (cultivo)", | |
| "8" => "Milf", _ => "Desconocido", | |
| }.to_string() | |
| } | |
| /// Helper function to map genre IDs to Spanish names. | |
| fn get_genre_name(id: &str) -> String { | |
| match id { | |
| "3" => "Acción", "29" => "Aventura", "18" => "Comedia", "1" => "Drama", | |
| "42" => "Recuentos de la vida", "2" => "Romance", "5" => "Venganza", "6" => "Harem", | |
| "23" => "Fantasía", "31" => "Sobrenatural", "25" => "Tragedia", "43" => "Psicológico", | |
| "32" => "Horror", "44" => "Thriller", "28" => "Historias cortas", "30" => "Ecchi", | |
| "34" => "Gore", "37" => "Girls love", "27" => "Boys love", "45" => "Reencarnación", | |
| "41" => "Sistema de niveles", "33" => "Ciencia ficción", "38" => "Apocalíptico", | |
| "39" => "Artes marciales", "40" => "Superpoderes", "35" => "Cultivación (cultivo)", | |
| "8" => "Milf", _ => "Desconocido", | |
| }.into() | |
| } |
There was a problem hiding this comment.
you should rename this to helpers.rs and move the other helper function(s) here.
| key: m.id_manhwa.clone().into(), | ||
| title: m.name_manhwa.clone(), | ||
| authors: Some(vec![subtitle]), | ||
| cover: m.img.clone().map(|s| s.into()), | ||
| url: Some(format!("{}/manhwa/{}", BASE_URL, m.id_manhwa)), |
There was a problem hiding this comment.
you shouldn't need to clone anything here. if you define the url above, before you use the key, that clone can be avoided, and if you use into_iter instead of iter that should allow the other two to be avoided.
| let id = name.split(':').nth(1).unwrap_or(""); | ||
| // Ensure 'creacion' (creation date) sort is properly applied for these listings too | ||
| let url = format!("{BACKEND_URL}/manhwa/library?page={}&perPage={}&erotico=no&generes={}&order_item=creacion&order_dir=desc", api_page, PER_PAGE, id); | ||
| let resp = crate::helper::request_with_limits(&url, "GET")?.send()?.get_json::<LibraryResponse>()?; |
There was a problem hiding this comment.
| let resp = crate::helper::request_with_limits(&url, "GET")?.send()?.get_json::<LibraryResponse>()?; | |
| let resp = crate::helper::request_with_limits(&url, "GET")?.json_owned::<LibraryResponse>()?; |
| } | ||
|
|
||
| impl LibraryManga { | ||
| pub fn to_manga(&self, base_url: &str) -> Manga { |
There was a problem hiding this comment.
this function should probably be consuming, and then you can avoid the clone()s. just make sure to use into_iter when collecting.
| pub fn to_manga(&self, base_url: &str) -> Manga { | |
| pub fn to_manga(self, base_url: &str) -> Manga { |
|
Thanks a lot for the feedback, I really appreciate it! I've reviewed all your comments and they should now be fixed. If there's anything else that needs to be changed, just let me know |
kkantan
left a comment
There was a problem hiding this comment.
looks good, there are just a few other things:
- json files still need tabs and newlines at the end.
- there are some clippy warnings you can see by running
cargo clippy. - there's still one extra newline in the
Cargo.tomlfile you could remove. - is there api support for fetching authors? it looks like the site has the names for some titles, for example "Inaka no Home Center Otoko no Jiyuu na Isekai Seikatsu" from the home page.
| } | ||
|
|
||
| impl LibraryManga { | ||
| pub fn to_manga(self, base_url: &str) -> Manga { |
There was a problem hiding this comment.
I believe that prefixing this with into_ instead will fix the clippy warning.
| pub fn to_manga(self, base_url: &str) -> Manga { | |
| pub fn into_manga(self, base_url: &str) -> Manga { |
| Manga { | ||
| key: m.id_manhwa.into(), | ||
| title: m.name_manhwa, | ||
| authors: Some(vec![subtitle]), |
There was a problem hiding this comment.
I think this is best to put as the description instead.
| } | ||
| } | ||
| } | ||
| FilterValue::Sort { index, .. } => { |
There was a problem hiding this comment.
since you don't use the ascending value, you should set canAscend to false in the filters.json.
|
|
||
| // Default to "no" erotic content if the filter wasn't explicitly set | ||
| if !erotic_filter_set { | ||
| qs.push("erotico", Some("no")); |
There was a problem hiding this comment.
this is the same thing for both the "no" option and the "ver todo" option.
since the source rating is set to 18+, and there's an 18+ listing, it seems like the default option should be "ver todo", if it can be made to work.
There was a problem hiding this comment.
I'd still prefer not to show 18+ content by default and keep it as an optional choice for the user. If we go with that approach, should we adjust how the source rating is handled or labeled to make it more consistent with a 'hidden by default' policy?
There was a problem hiding this comment.
in that case, you should remove the 18+ listing and then change the contentRating in the source.json to 1 instead of 2.
New Source: Es.manhwaweb
Description
This PR adds a new source for ManhwaWeb (Spanish web).
Features
Verification
I have manually built the package and tested it on an iPhone:
This is my first contribution to Aidoku! I'm happy to help the community. I'll be waiting for any feedback or requested changes. Thanks for all the great work all has been doing