Documentation
¶
Index ¶
- func DownloadImages(ctx context.Context, urls []string, cacheDir string) (map[string]string, error)
- func ExtractImageURLs(md string) []string
- func ImageFileName(u string) string
- func ImageID(url string) uint32
- func IsYouTubeURL(raw string) bool
- func ToPNG(data []byte) ([]byte, image.Point, error)
- func WriteOPML(w io.Writer, title string, feeds []OPMLEntry) error
- type FetchResult
- type Fetcher
- func (f *Fetcher) FetchAll(ctx context.Context) ([]FetchResult, error)
- func (f *Fetcher) FetchFull(ctx context.Context, articleURL string) (string, error)
- func (f *Fetcher) FetchFullWithTitle(ctx context.Context, articleURL string) (string, string, error)
- func (f *Fetcher) FetchOne(ctx context.Context, feed db.Feed) (FetchResult, error)
- func (f *Fetcher) ResolveYouTube(ctx context.Context, raw string) (ResolvedFeed, bool, error)
- type OPMLEntry
- type ResolvedFeed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadImages ¶
DownloadImages fetches all URLs into cacheDir, returning a url→path map. Files are named after the SHA256 of the URL so the same URL resolves to the same path across runs. Already-cached URLs are skipped; network errors on individual URLs are logged-and-ignored so one bad image doesn't break the batch.
func ExtractImageURLs ¶ added in v0.8.0
ExtractImageURLs scans the markdown for `` references and returns URLs in the order they appear, deduplicated. URLs without a scheme are skipped (local/relative refs aren't reachable here). SVG URLs are also dropped: Go's stdlib image package can't decode SVG, so ToPNG would fail per image — skipping them keeps the log clean and saves a wasted network round-trip.
func ImageFileName ¶
ImageFileName returns a deterministic filename for the given image URL. The filename is the first 16 bytes of the URL's SHA256 in hex, plus the URL's file extension (if it's a sane-looking ASCII extension).
func ImageID ¶ added in v0.8.0
ImageID returns a deterministic 24-bit image ID derived from the URL. We fold SHA256 down to 24 bits so the low bytes fit in a standard truecolor FG triple (used by older placeholder approach). IDs are not strictly unique but collisions across one article are vanishingly rare and tolerable.
func IsYouTubeURL ¶ added in v0.11.0
IsYouTubeURL reports whether raw points at a YouTube host we know how to resolve to the built-in channel RSS feed.
Types ¶
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
func (*Fetcher) FetchFullWithTitle ¶ added in v0.7.0
func (f *Fetcher) FetchFullWithTitle(ctx context.Context, articleURL string) (string, string, error)
FetchFullWithTitle fetches a URL, extracts the main article via go-readability, and returns the page title alongside the Markdown body. Title is whatever readability resolved (often the <title> tag or first <h1>); callers should keep their own placeholder when this returns an empty string.
func (*Fetcher) ResolveYouTube ¶ added in v0.11.0
ResolveYouTube resolves a YouTube channel/handle/video URL to YouTube's RSS endpoint: https://www.youtube.com/feeds/videos.xml?channel_id=...
type ResolvedFeed ¶ added in v0.11.0
ResolvedFeed is a user-facing URL resolved to an RSS/Atom feed URL.