diff --git a/src/commands/download.rs b/src/commands/download.rs index 1d80cfc..32772ae 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs @@ -42,7 +42,7 @@ pub async fn run(args: env::Args) { _ => panic!("Got a weird error while creating dir: {}", err) } }; - let mut page_num: usize = 1; + let mut page_num: i32 = 1; for page in sauce_info.images.pages { let file_ext = match page.t.as_str() { "j" => ".jpg", diff --git a/src/commands/view.rs b/src/commands/view.rs index 5de670d..d6e9262 100644 --- a/src/commands/view.rs +++ b/src/commands/view.rs @@ -16,7 +16,7 @@ pub async fn run(args: env::Args) { exit(1); } let client = reqwest::Client::new(); - let mut handles: Vec> = Vec::with_capacity(sauces.len()); + let mut handles: Vec> = Vec::with_capacity(sauces.len()); for sauce in sauces { let cloned_client = client.clone(); handles.push(tokio::spawn(async move { diff --git a/src/structs.rs b/src/structs.rs index ddc342c..dbb773e 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -10,8 +10,8 @@ pub struct GalleryTitleInfo { #[derive(Deserialize, Debug)] pub struct GalleryImageInfo { pub t: String, - pub w: usize, - pub h: usize + pub w: i32, + pub h: i32 } #[derive(Deserialize, Debug)] @@ -23,24 +23,24 @@ pub struct GalleryImagesInfo { #[derive(Deserialize, Debug)] pub struct GalleryTagInfo { - pub id: usize, + pub id: i32, pub r#type: String, pub name: String, pub url: String, - pub count: usize + pub count: i32 } #[derive(Deserialize, Debug)] pub struct GalleryInfoSuccess { - pub id: usize, + pub id: i32, pub media_id: String, pub title: GalleryTitleInfo, pub images: GalleryImagesInfo, pub scanlator: String, - pub upload_date: usize, + pub upload_date: i32, pub tags: Vec, - pub num_pages: usize, - pub num_favorites: usize + pub num_pages: i32, + pub num_favorites: i32 } #[derive(Deserialize, Debug)] @@ -58,6 +58,6 @@ pub enum GalleryInfo { #[derive(Deserialize, Debug)] pub struct SearchInfo { pub result: Vec, - pub num_pages: usize, - pub per_page: usize + pub num_pages: i32, + pub per_page: i32 } diff --git a/src/utils.rs b/src/utils.rs index 40c2e14..78ff89f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -11,13 +11,13 @@ extern crate reqwest; fn fix_gallery(body: &mut serde_json::Value) -> Result<(), serde_json::Error> { if body["id"].is_string() { body["id"] = serde_json::json!( - body["id"].as_str().unwrap().parse::().unwrap() + body["id"].as_str().unwrap().parse::().unwrap() ); } Ok(()) } -pub async fn get_sauce_info(client: reqwest::Client, sauce: usize) -> Result { +pub async fn get_sauce_info(client: reqwest::Client, sauce: i32) -> Result { let mut uri = String::from("https://nhentai.net/api/gallery/"); uri.push_str(&sauce.to_string()); let resp = client.get(&uri) @@ -56,10 +56,10 @@ pub async fn download_file(client: reqwest::Client, url: &str, file_name: &str) Ok(()) } -pub fn get_arg_sauces(args: env::Args) -> Result, String> { - let mut sauces: Vec = Vec::new(); +pub fn get_arg_sauces(args: env::Args) -> Result, String> { + let mut sauces: Vec = Vec::new(); for sauce in args { - let sauce: usize = match sauce.parse() { + let sauce: i32 = match sauce.parse() { Ok(sauce) => sauce, Err(_) => { return Err(format!("{} is not a number/sauce", sauce));