aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-03-03 08:09:50 +0300
committerA Farzat <a@farzat.xyz>2026-03-03 08:09:50 +0300
commitc0e92932f83ece433426d7e711c5165420a71e6c (patch)
treefad2d23e07586c1dd19b332c7b0b94fe87ff4def /src/main.rs
parent3558106317184cb41367007150f252fe1a9e9eeb (diff)
downloadoreilly-epub-c0e92932f83ece433426d7e711c5165420a71e6c.tar.gz
oreilly-epub-c0e92932f83ece433426d7e711c5165420a71e6c.zip
Remove the search endpoint
It is not the best idea as it is non-deterministic, working on the assumption that searching by ISBN would return the book and in a consistent way. The contents previously extracted from it, such as authors and publishers, are already included in the OPF file which can be fetched from the files list. Further items such as description can be fetched from the metadata endpoint later if needed.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/main.rs b/src/main.rs
index 34cc200..34d4d51 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,7 +6,7 @@ use std::collections::HashMap;
use anyhow::{Context, Result, ensure};
use clap::Parser;
use http_client::build_authenticated_client;
-use models::{Chapter, EpubResponse, FileEntry, Paginated, SearchResult, SpineItem, TocNode};
+use models::{Chapter, EpubResponse, FileEntry, Paginated, SpineItem, TocNode};
use reqwest::Client;
/// Download and generate an EPUB from Safari Books Online.
@@ -95,24 +95,10 @@ async fn main() -> Result<()> {
let client = build_authenticated_client(&args.cookies)?;
println!("Fetching book metadata...");
- // Fetch from the search API.
- let search_url = format!(
- "https://learning.oreilly.com/api/v2/search/?query={}",
- args.bookid
- );
- let search_data: Vec<SearchResult> = fetch_all_pages(&client, search_url).await?;
- if let Some(book) = search_data.first() {
- println!("\n--- Book Found ---");
- println!("Title: {}", book.title);
- println!("Authors: {}", book.authors.join(", "));
- println!("Publisher: {}", book.publishers.join(", "));
- println!("Cover URL: {}", book.cover_url);
- } else {
- anyhow::bail!("Could not find book metadata for ID: {}", args.bookid);
- }
// Fetch from the EPUB API.
let epub_data = fetch_epub_data(&client, &args.bookid).await?;
println!("Publication date: {}", epub_data.publication_date);
+ println!("Title: {}", epub_data.title);
println!("Chapters URL: {}", epub_data.chapters);
println!("Resources URL: {}", epub_data.files);
println!("------------------\n");