@@ -20,6 +20,7 @@ const (
2020 RequestTypePDF RequestType = "pdf"
2121 RequestTypeContent RequestType = "content"
2222 RequestTypeMetadata RequestType = "metadata"
23+ RequestTypeAnimated RequestType = "animated"
2324)
2425
2526type RequestOptions map [string ]interface {}
@@ -77,10 +78,6 @@ func (c *Capture) toQueryString(options RequestOptions) string {
7778 params := make (map [string ]string )
7879
7980 for key , value := range options {
80- if key == "format" {
81- continue
82- }
83-
8481 if value == nil || value == "" {
8582 continue
8683 }
@@ -171,6 +168,10 @@ func (c *Capture) BuildMetadataURL(targetURL string, options RequestOptions) (st
171168 return c .buildURL (RequestTypeMetadata , targetURL , options )
172169}
173170
171+ func (c * Capture ) BuildAnimatedURL (targetURL string , options RequestOptions ) (string , error ) {
172+ return c .buildURL (RequestTypeAnimated , targetURL , options )
173+ }
174+
174175func (c * Capture ) FetchImage (targetURL string , options RequestOptions ) ([]byte , error ) {
175176 url , err := c .BuildImageURL (targetURL , options )
176177 if err != nil {
@@ -223,6 +224,7 @@ type ContentResponse struct {
223224 Success bool `json:"success"`
224225 HTML string `json:"html"`
225226 TextContent string `json:"textContent"`
227+ Markdown string `json:"markdown"`
226228}
227229
228230func (c * Capture ) FetchContent (targetURL string , options RequestOptions ) (* ContentResponse , error ) {
@@ -276,4 +278,28 @@ func (c *Capture) FetchMetadata(targetURL string, options RequestOptions) (*Meta
276278 }
277279
278280 return & metadataResp , nil
281+ }
282+
283+ func (c * Capture ) FetchAnimated (targetURL string , options RequestOptions ) ([]byte , error ) {
284+ url , err := c .BuildAnimatedURL (targetURL , options )
285+ if err != nil {
286+ return nil , err
287+ }
288+
289+ resp , err := c .Client .Get (url )
290+ if err != nil {
291+ return nil , fmt .Errorf ("failed to fetch animated: %w" , err )
292+ }
293+ defer resp .Body .Close ()
294+
295+ if resp .StatusCode != http .StatusOK {
296+ return nil , fmt .Errorf ("HTTP error: %d" , resp .StatusCode )
297+ }
298+
299+ buf , err := io .ReadAll (resp .Body )
300+ if err != nil {
301+ return nil , fmt .Errorf ("failed to read response body: %w" , err )
302+ }
303+
304+ return buf , nil
279305}
0 commit comments