diff options
| author | Mariot Tsitoara <[email protected]> | 2021-01-02 10:31:21 +0100 |
|---|---|---|
| committer | Mariot Tsitoara <[email protected]> | 2021-01-02 10:31:21 +0100 |
| commit | 3a3e59a26a8233908f5ab9887501cbe93836a437 (patch) | |
| tree | 1882ecf827f2c842b6e9ff0cc35cbd51bd5a5842 /src/bin.rs | |
| parent | Add lib examples to README (diff) | |
| download | chan-downloader-3a3e59a26a8233908f5ab9887501cbe93836a437.tar.xz chan-downloader-3a3e59a26a8233908f5ab9887501cbe93836a437.zip | |
Use reqwest blocking client
Diffstat (limited to 'src/bin.rs')
| -rw-r--r-- | src/bin.rs | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -6,7 +6,8 @@ use std::fs::create_dir_all; use clap::App; use indicatif::{ProgressBar, ProgressStyle}; -use reqwest::Client; +use reqwest::Error; +use reqwest::blocking::Client; use chan_downloader::{get_image_links, get_page_content, get_thread_infos, save_image}; @@ -16,11 +17,11 @@ fn main() { let thread = matches.value_of("thread").unwrap(); let output = matches.value_of("output").unwrap_or("downloads"); - download_thread(thread, &output); + download_thread(thread, &output).unwrap(); } -fn download_thread(thread_link: &str, output: &str) { - let client = Client::new(); +fn download_thread(thread_link: &str, output: &str) -> Result<(), Error> { + let client = Client::builder().user_agent("reqwest").build()?; let workpath = env::current_dir().unwrap(); let (board_name, thread_id) = get_thread_infos(thread_link); @@ -60,4 +61,5 @@ fn download_thread(thread_link: &str, output: &str) { } Err(err) => eprintln!("Error: {}", err), } + Ok(()) } |