news

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheAge

func CacheAge(cacheDir string) time.Duration

CacheAge returns the age of the news cache, or -1 if it doesn't exist.

func SaveCache

func SaveCache(cacheDir string, items []NewsItem) error

SaveCache writes correlated news items to disk.

Types

type NewsItem

type NewsItem struct {
	Episode   youtube.Episode
	Community *community.BlogPost // nil if no match within ±7 days
}

NewsItem pairs a YouTube episode with its matched Community blog post (if any).

func Correlate

func Correlate(episodes []youtube.Episode, posts []community.BlogPost) []NewsItem

Correlate pairs each episode with the closest Community post within ±7 days. When multiple posts are within the window, the one with the highest title similarity (longest common substring length) wins. Each post is used at most once — episodes are matched in order, and once a post is claimed, later episodes cannot reuse it. Episodes with no match have Community set to nil. Input episode order is preserved.

func LoadBaseline

func LoadBaseline(officialCacheDir string) ([]NewsItem, bool)

LoadBaseline reads a pre-fetched news-episodes.json from the content pack. This file is committed by a GitHub Action and pulled during sync.

func LoadCache

func LoadCache(cacheDir string, ttl time.Duration) ([]NewsItem, bool)

LoadCache reads cached news items if the cache exists and is fresher than ttl.

func LoadCacheStale

func LoadCacheStale(cacheDir string) ([]NewsItem, bool)

LoadCacheStale reads cached news items ignoring TTL. Used as fallback when live fetches fail.

Jump to

Keyboard shortcuts

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