diff options
| author | A Farzat <a@farzat.xyz> | 2026-02-12 14:23:43 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2026-02-12 14:23:43 +0300 |
| commit | 57bc69a7f9af497526695e5a0bfbc60939f667e9 (patch) | |
| tree | 10d70a1334128cf8894d0c759b8dac2b3d752968 /src/main.rs | |
| parent | 2d9314aa3145ec7948341f38164e13c2a2d945ad (diff) | |
| download | safaribooks-rs-57bc69a7f9af497526695e5a0bfbc60939f667e9.tar.gz safaribooks-rs-57bc69a7f9af497526695e5a0bfbc60939f667e9.zip | |
Add the ability to fetch book info
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index f79f191..d393a55 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,8 +10,7 @@ use cli::Args; use cookies::CookieStore; use display::Display; use http_client::HttpClient; -use orly::check_login; -use reqwest::Client; +use orly::{check_login, fetch_book_info}; #[tokio::main] async fn main() { @@ -60,6 +59,14 @@ async fn main() { Err(e) => ui.error_and_exit(&format!("Login check failed: {e}")), }; + // Retrieve book info. + ui.info("Retrieving book info..."); + let bookinfo = match fetch_book_info(&client, &args.bookid).await { + Ok(info) => info, + Err(e) => ui.error_and_exit(&format!("Failed to fetch book info: {}", e)), + }; + ui.info(&format!("{:#?}", bookinfo)); + let output_dir = config::books_root().join(format!("(pending) ({})", args.bookid)); ui.set_output_dir(output_dir); |
