Skip to content

Commit

Permalink
fix(libgroup): add user-agent at every request & change api domain
Browse files Browse the repository at this point in the history
  • Loading branch information
vlapsk1y committed Nov 14, 2024
1 parent de706bf commit f4c7a27
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/rust/multi.libgroup/template/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub struct CDN {
pub compress: &'static str,
}

static DOMAIN_API: &str = "https://api.lib.social/api/";
static USER_AGENT: &str = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1";
static DOMAIN_API: &str = "https://api.mangalib.me/api/";

impl SocialLibSource {
pub fn get_manga_list(&self, filters: Vec<Filter>, page: i32) -> Result<MangaPageResult> {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -86,7 +93,9 @@ impl SocialLibSource {
pub fn get_chapter_list(&self, id: String) -> Result<Vec<Chapter>> {
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)
Expand All @@ -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)
Expand Down

0 comments on commit f4c7a27

Please sign in to comment.