meta

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package meta fetches game metadata and art: descriptions, developers, genres, controller support, covers, hero banners, logos and icons, from Steam (no key needed), GOG and, with the user's key, SteamGridDB. Every image is downloaded from an allowlisted host, decoded, resized and re-encoded before it is stored, so nothing but plain pixels reaches the interface.

Index

Constants

View Source
const Version = 4

Version marks what Fetch gathers; metadata from an older version is fetched again (2: backdrops; 3: full-size backdrops, round tiles, Steam's own art files when its store lists none; 4: PCGamingWiki's controller support, the Epic store's art for games only Epic sells, backdrops picked from several and kept up to 4K).

Variables

View Source
var ErrNotAllowed = errors.New("host not allowed")

ErrNotAllowed means a URL points somewhere Seaglass doesn't fetch from.

View Source
var ErrRateLimited = errors.New("rate limited")

ErrRateLimited means a source asked us to slow down.

Functions

func Accent

func Accent(img image.Image) string

Accent picks a lively colour from an image: the most prominent hue among saturated, bright-enough pixels, brought to a lightness that reads on a dark background. "" when the image is too grey.

func ArtHandler

func ArtHandler(artDir string) func(http.Handler) http.Handler

ArtHandler serves stored art under /art/ to the interface, and passes every other request on.

func ImageHandler added in v1.6.0

func ImageHandler(prefix, dir string) func(http.Handler) http.Handler

ImageHandler serves the images stored in dir (content-addressed, as StoreImage names them) under prefix, and passes every other request on.

func IsStoredArt

func IsStoredArt(artDir, url string) bool

IsStoredArt reports whether url names an image stored in artDir.

func PruneArt

func PruneArt(artDir string, keep map[string]bool, grace time.Duration) (removed int, freed int64)

PruneArt deletes stored images no game uses anymore (art replaced by a refresh, games removed) and leftovers of cut-short writes. keep holds the art URLs in use. Files younger than grace stay: a fetch may be about to use them.

func SetArt

func SetArt(m *library.Meta, kind Kind, art string, artDir string) bool

SetArt makes a stored picture the game's art of a kind, and keeps it through later metadata refreshes. It reports false for a kind that can't be chosen or a name that isn't stored art.

func StoreImage added in v1.6.0

func StoreImage(dir string, data []byte, kind Kind) (string, error)

StoreImage checks image data (a local file, say), re-encodes it at the kind's size and stores it in dir, returning the stored file's name.

Types

type Choice

type Choice struct {
	Art    string `json:"art"` // /art/… URL
	Source string `json:"source"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

Choice is one picture a game's art can be changed to: already stored (the interface only shows local art), with where it came from.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the metadata sources.

func NewClient

func NewClient(artDir string, sgdbKey func() string) *Client

NewClient stores art in artDir; sgdbKey returns the SteamGridDB key ("" = none).

func (*Client) ArtChoices

func (c *Client) ArtChoices(ctx context.Context, r Request, kind Kind, current *library.Meta) ([]Choice, error)

ArtChoices gathers the pictures a game's cover, backdrop, hero or logo could be: what Steam has (its library art and every screenshot), the Epic store's page for a game only Epic sells, PCGamingWiki's cover and, with a key, SteamGridDB's community art. Each is downloaded and stored the way fetched art is. The current picture comes first.

func (*Client) BaseGame

func (c *Client) BaseGame(ctx context.Context, appID int) (StoreHit, bool)

BaseGame is the game a DLC belongs to; false when appID is a game itself (or the store doesn't say). A folder named after a game's expansion ("Cyberpunk 2077 Phantom Liberty") holds the game.

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, r Request) (*library.Meta, error)

Fetch gathers metadata and art for one game. Missing pieces are simply left empty; an error means nothing at all could be fetched (and is ErrRateLimited when the caller should back off).

func (*Client) FetchImage added in v1.6.0

func (c *Client) FetchImage(ctx context.Context, src, dir string, kind Kind) (string, error)

FetchImage downloads an image from an allowlisted host and stores it like StoreImage.

func (*Client) PCGamingWiki

func (c *Client) PCGamingWiki(ctx context.Context, title string) (*PCGW, error)

PCGamingWiki looks a game up by title. The wiki's redirects cover most other spellings ("Alan Wake 2" → "Alan Wake II"); a title ending in a number is also tried with the other kind of numeral.

func (*Client) SearchSteam

func (c *Client) SearchSteam(ctx context.Context, term string) ([]StoreHit, error)

SearchSteam looks a title up on the Steam store.

func (*Client) UseTransport

func (c *Client) UseTransport(rt http.RoundTripper)

UseTransport sends requests through rt and drops the waits between them: for tests that record and replay the sources' answers (rt then spaces out the requests that really go out).

type Kind

type Kind string

Kind is which picture of a game an image is.

const (
	Cover    Kind = "cover"    // portrait, 2:3
	Hero     Kind = "hero"     // wide banner behind the details
	Backdrop Kind = "backdrop" // 16:9, sharp enough to fill the big picture screen
	Tile     Kind = "tile"     // square: key art with the logo, for round tiles
	Icon     Kind = "icon"
)

type PCGW

type PCGW struct {
	Title       string // the page's name: the game's usual title
	SteamAppID  int
	GogID       string
	EpicSlug    string // the Epic store page (store.epicgames.com/p/<slug>)
	Cover       string // file name on the wiki
	Developers  []string
	ReleaseDate string
	Genres      []string
	// Controllers: DualSense is "yes" (DualSense or DualSense Edge
	// supported), "dualshock" (DualShock 4 only), "no" (no PlayStation
	// controllers) or "" (the page doesn't say); Controller is "full",
	// "partial" or "".
	DualSense  string
	Controller string
}

PCGW is what a PCGamingWiki page says about a game.

type Request

type Request struct {
	Title      string
	SteamAppID int
	GogID      string
	EpicApp    string        // namespace:item:appName, for games Steam doesn't have
	Keep       *library.Meta // previous metadata: user-chosen art is kept
	// PCGW is the game's PCGamingWiki page when the caller already looked
	// it up; otherwise Fetch looks it up by Title.
	PCGW *PCGW
}

Request says which game to fetch metadata for.

type StoreHit

type StoreHit struct {
	AppID int    `json:"appId"`
	Name  string `json:"name"`
	Image string `json:"image"` // small capsule on Steam's CDN (not fetched by Seaglass)
}

StoreHit is one result of a Steam store search.

Jump to

Keyboard shortcuts

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