diff --git a/deviantart-cli/Cargo.toml b/deviantart-cli/Cargo.toml index eb152f54..2269d866 100644 --- a/deviantart-cli/Cargo.toml +++ b/deviantart-cli/Cargo.toml @@ -7,9 +7,20 @@ license = "MIT OR Apache-2.0" [dependencies] argh = "0.1.12" anyhow = "1.0.86" -deviantart = { path = "../deviantart" } +deviantart = { path = "../deviantart", default-features = false } directories-next = "2.0.0" nd-util = { git = "https://github.com/nathaniel-daniel/nd-util-rs", features = [ "download-to-path" ] } toml = { version = "0.8.19", features = [ "preserve_order" ] } tokio = { version = "1.40.0", features = [ "rt-multi-thread", "fs" ] } serde = { version = "1.0.209", features = [ "derive" ] } + +[features] +default = [ + "rustls-tls", +] +native-tls = [ + "deviantart/native-tls", +] +rustls-tls = [ + "deviantart/rustls-tls", +] diff --git a/deviantart/src/client.rs b/deviantart/src/client.rs index 3966e44d..07e8c20e 100644 --- a/deviantart/src/client.rs +++ b/deviantart/src/client.rs @@ -302,9 +302,13 @@ impl SearchCursor { browse_page_stream .items .iter() + .filter_map(|id| { + // TODO: Investigate string format more. + id.as_u64() + }) .map(|id| { - page.get_deviation_by_id(*id) - .ok_or(Error::MissingDeviation(*id)) + page.get_deviation_by_id(id) + .ok_or(Error::MissingDeviation(id)) }) .collect(), ) @@ -326,9 +330,13 @@ impl SearchCursor { Some( items .iter() + .filter_map(|id| { + // TODO: Investigate string format more. + id.as_u64() + }) .map(|id| { - page.take_deviation_by_id(*id) - .ok_or(Error::MissingDeviation(*id)) + page.take_deviation_by_id(id) + .ok_or(Error::MissingDeviation(id)) }) .collect(), ) diff --git a/deviantart/src/types/scraped_webpage_info.rs b/deviantart/src/types/scraped_webpage_info.rs index 5a28bfcf..35f7561c 100644 --- a/deviantart/src/types/scraped_webpage_info.rs +++ b/deviantart/src/types/scraped_webpage_info.rs @@ -62,8 +62,7 @@ impl ScrapedWebPageInfo { /// Parse this from a html string pub fn from_html_str(input: &str) -> Result { static REGEX: Lazy = Lazy::new(|| { - Regex::new(r#"window\.__INITIAL_STATE__ = JSON\.parse\("(.*)"\);"#) - .expect("invalid `scrape_deviation` regex") + Regex::new(r#"window\.__INITIAL_STATE__ = JSON\.parse\("(.*)"\);"#).unwrap() }); let capture = REGEX @@ -268,8 +267,12 @@ pub struct BrowsePageStream { #[serde(rename = "hasMore")] pub has_more: bool, - /// deviation ids - pub items: Vec, + /// Deviation ids? + /// + /// Usually, these are integers representing deviation ids. + /// In some cases, these are strings of the format "xx-nnnnn", + /// where the "xx" part is unknown and the "nnnnn" part is a deviation id. + pub items: Vec, /// The # of items per page #[serde(rename = "itemsPerFetch")]