Skip to content

Commit 478fd2b

Browse files
committed
Add animated
1 parent d81bd94 commit 478fd2b

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "capture-rust"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
description = "Rust SDK for capture.page - Browser automation and screenshot API"
66
license = "MIT"

src/lib.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub enum RequestType {
2626
Pdf,
2727
Content,
2828
Metadata,
29+
Animated,
2930
}
3031

3132
impl RequestType {
@@ -35,6 +36,7 @@ impl RequestType {
3536
RequestType::Pdf => "pdf",
3637
RequestType::Content => "content",
3738
RequestType::Metadata => "metadata",
39+
RequestType::Animated => "animated",
3840
}
3941
}
4042
}
@@ -444,6 +446,7 @@ pub struct ContentResponse {
444446
pub html: String,
445447
#[serde(rename = "textContent")]
446448
pub text_content: String,
449+
pub markdown: String,
447450
}
448451

449452
#[derive(Debug, Deserialize)]
@@ -525,10 +528,6 @@ impl Capture {
525528
let mut params = Vec::new();
526529

527530
for (key, value) in options {
528-
if key == "format" {
529-
continue;
530-
}
531-
532531
let value_str = match value {
533532
serde_json::Value::String(s) => s.clone(),
534533
serde_json::Value::Number(n) => n.to_string(),
@@ -607,6 +606,10 @@ impl Capture {
607606
self.build_url(RequestType::Metadata, url, options)
608607
}
609608

609+
pub fn build_animated_url(&self, url: &str, options: Option<&RequestOptions>) -> Result<String> {
610+
self.build_url(RequestType::Animated, url, options)
611+
}
612+
610613
// Structured options methods
611614
pub fn build_screenshot_url(
612615
&self,
@@ -684,6 +687,17 @@ impl Capture {
684687
Ok(metadata)
685688
}
686689

690+
pub async fn fetch_animated(
691+
&self,
692+
url: &str,
693+
options: Option<&RequestOptions>,
694+
) -> Result<Vec<u8>> {
695+
let capture_url = self.build_animated_url(url, options)?;
696+
let response = self.client.get(&capture_url).send().await?;
697+
let bytes = response.bytes().await?;
698+
Ok(bytes.to_vec())
699+
}
700+
687701
// Structured options fetch methods
688702
pub async fn fetch_screenshot(
689703
&self,

0 commit comments

Comments
 (0)