From d95c61a54d7eef1eb091b7bc471d7b9d2c546295 Mon Sep 17 00:00:00 2001 From: Vova Lapskiy Date: Sun, 17 Nov 2024 19:57:26 +0500 Subject: [PATCH] fix(mangalib): update url to manga & one more thing (#795) * fix(mangalib): update URL to manga * fix(libgroup): display date of upload chapter * fix(libgroup): determine MangaViewer * fix(libgroup): add user-agent at every request & change api domain * fix(libgroup): I forgot remove println --- .../sources/mangalib/res/source.json | 2 +- .../multi.libgroup/template/src/parser.rs | 33 ++++++++++++------- .../multi.libgroup/template/src/template.rs | 23 +++++++++---- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/rust/multi.libgroup/sources/mangalib/res/source.json b/src/rust/multi.libgroup/sources/mangalib/res/source.json index 3083a6da1..6ae13be69 100644 --- a/src/rust/multi.libgroup/sources/mangalib/res/source.json +++ b/src/rust/multi.libgroup/sources/mangalib/res/source.json @@ -3,7 +3,7 @@ "id": "ru.mangalib", "lang": "ru", "name": "MangaLib", - "version": 1, + "version": 2, "url": "https://mangalib.me", "nsfw": 1 }, diff --git a/src/rust/multi.libgroup/template/src/parser.rs b/src/rust/multi.libgroup/template/src/parser.rs index ec0823129..1ab9eb17d 100644 --- a/src/rust/multi.libgroup/template/src/parser.rs +++ b/src/rust/multi.libgroup/template/src/parser.rs @@ -111,16 +111,9 @@ pub fn parse_manga_details( let description = detail.get("summary").as_string()?.read(); let url = format!( - "https://{}/{}", + "https://{}/ru/manga/{}", domain, - detail - .get("slug_url") - .as_string()? - .read() - .split("--") - .collect::>() - .get(1) - .unwrap() + detail.get("slug_url").as_string()?.read() ); let categories: Vec = detail @@ -144,7 +137,18 @@ pub fn parse_manga_details( let nsfw = *is_nsfw; - let viewer = MangaViewer::Rtl; + let viewer = if detail + .get("type") + .as_object()? + .get("id") + .as_int() + .unwrap_or_default() + == 5 + { + MangaViewer::Scroll + } else { + MangaViewer::Rtl + }; Ok(Manga { id, @@ -197,7 +201,14 @@ pub fn parse_chapter_list(js: ObjectRef, id: &str, domain: &str) -> Result, page: i32) -> Result { @@ -41,7 +42,9 @@ impl SocialLibSource { } let url = format!("{}manga?{}", DOMAIN_API, query); - let request = Request::new(url, HttpMethod::Get).header("Site-Id", self.site_id); + let request = Request::new(url, HttpMethod::Get) + .header("Site-Id", self.site_id) + .header("User-Agent", USER_AGENT); let json = request.json()?.as_object()?; parser::parse_manga_list(json, &self.domain.to_string(), self.nsfw) @@ -56,7 +59,9 @@ impl SocialLibSource { let query = qs.to_string(); let url = format!("{}media/top-views?{}", DOMAIN_API, query); - let request = Request::new(url, HttpMethod::Get).header("Site-Id", self.site_id); + let request = Request::new(url, HttpMethod::Get) + .header("Site-Id", self.site_id) + .header("User-Agent", USER_AGENT); let json = request.json()?.as_object()?; parser::parse_manga_list(json, &self.domain.to_string(), self.nsfw) @@ -77,7 +82,9 @@ impl SocialLibSource { query.push("fields[]", Some("status_id")); query.push("fields[]", Some("artists")); let url = format!("{}manga/{}?{}", DOMAIN_API, id, query.to_string()); - let request = Request::new(url, HttpMethod::Get).header("Site-Id", self.site_id); + let request = Request::new(url, HttpMethod::Get) + .header("Site-Id", self.site_id) + .header("User-Agent", USER_AGENT); let json = request.json()?.as_object()?; parser::parse_manga_details(json, self.domain, self.nsfw) @@ -86,7 +93,9 @@ impl SocialLibSource { pub fn get_chapter_list(&self, id: String) -> Result> { let url = format!("{}manga/{}/chapters", DOMAIN_API, id); - let request = Request::new(url, HttpMethod::Get).header("Site-Id", self.site_id); + let request = Request::new(url, HttpMethod::Get) + .header("Site-Id", self.site_id) + .header("User-Agent", USER_AGENT); let json = request.json()?.as_object()?; parser::parse_chapter_list(json, &id, self.domain) @@ -102,7 +111,9 @@ impl SocialLibSource { numbers.first().unwrap(), numbers.get(1).unwrap() ); - let request = Request::new(url, HttpMethod::Get).header("Site-Id", self.site_id); + let request = Request::new(url, HttpMethod::Get) + .header("Site-Id", self.site_id) + .header("User-Agent", USER_AGENT); let json = request.json()?.as_object()?; parser::parse_page_list(json, self.cdn)