images

package
v0.62.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package images downloads the images a task links, so an agent reads local files instead of fetching urls that expire (Notion's signed links) or need auth its fetch tool lacks (a private repo's attachments).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Footer(results []Result) string

Footer is what follows the document: a line naming each local path, and a line naming each image that failed with its reason; "" for no results.

func Links(doc string) []string

Links is every image url doc links, in order of first appearance, each once: markdown and HTML image syntax with any url, and bare urls whose path ends in an image extension.

Types

type Downloader

type Downloader struct {
	Client    *http.Client
	Authorize func(*http.Request)
}

A Downloader fetches images. Authorize may add credentials to each first request; the client decides what survives a redirect. A nil Client refuses local addresses, since the urls come from task text anyone may have written.

func (Downloader) Download

func (d Downloader) Download(ctx context.Context, dir string, urls []string) ([]Result, error)

Download fetches up to maxImages urls into dir, numbered in link order; the rest fail as over the limit. The set lands in a sibling and replaces dir whole, so a concurrent read never sees a half-written or emptied dir.

type Result

type Result struct {
	URL  string
	Path string
	Err  error
}

A Result is one image: where it landed, or why it did not.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL