romm

package
v2.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: GPL-3.0 Imports: 29 Imported by: ? 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 romm reads a self-hosted RomM server: its platforms and ROMs become indexed media, and a ROM is downloaded onto the device when launched.

Index

Constants

View Source
const LauncherID = "RomM"

LauncherID names the RomM launcher, and is the launcher a [[launchers.default]] entry names to set the server_url.

Variables

View Source
var (
	// ErrNotConfigured is returned when no RomM server URL is set.
	ErrNotConfigured = errors.New("romm server is not configured")
	// ErrUnauthorized is returned when the server refuses the stored token.
	ErrUnauthorized = errors.New("romm server refused the credentials")
	// ErrNotFound is returned for a ROM the server does not have.
	ErrNotFound = errors.New("romm rom not found")
)
View Source
var (
	// ErrLinkPending means the user has not approved the request yet.
	ErrLinkPending = errors.New("romm link approval pending")
	// ErrLinkSlowDown means the device polled faster than the server allows.
	ErrLinkSlowDown = errors.New("romm link polled too fast")
	// ErrLinkDenied means the user turned the request down.
	ErrLinkDenied = errors.New("romm link request denied")
	// ErrLinkExpired means the request expired or was already used.
	ErrLinkExpired = errors.New("romm link request expired")
)

Errors a device-token poll ends with, by RomM's OAuth device-flow codes.

View Source
var DeviceScopes = []string{"platforms.read", "roms.read", "assets.read"}

DeviceScopes are the permissions a linked device asks for: enough to list platforms and ROMs, download them and fetch their artwork.

View Source
var ErrInvalidPath = errors.New("invalid romm path")

ErrInvalidPath is returned for a romm:// path without a usable ROM ID.

Functions

func Install

func Install(
	ctx context.Context,
	cfg *config.Instance,
	pl platforms.Platform,
	ui *uievents.Service,
	p string,
) (localPath, systemID string, err error)

Install downloads the ROM a romm:// path names into its system's game folder, unless it is there already, and returns the local file to launch and the system it belongs to.

func IsRomPath

func IsRomPath(p string) bool

IsRomPath reports whether path uses the romm:// scheme, valid or not.

func IsUnreachable

func IsUnreachable(err error) bool

IsUnreachable reports whether err means the server could not be reached or failed on its side, rather than refusing or answering badly.

func LaunchExtensions

func LaunchExtensions(cfg *config.Instance, pl platforms.Platform, systemID string) []string

LaunchExtensions are the lowercase extensions the platform's file launchers for a system open. RomM ROMs a system cannot open are not listed for it, and an extracted multi-file game is started from a file of one of these.

func LocalNames

func LocalNames(rom *Rom, l Layout) []string

LocalNames are the lowercase file names that mean a ROM is already on the device: any of its files, and the playlist a multi-file ROM is launched by.

func MatchNames

func MatchNames(rom *Rom) []string

MatchNames are the lowercase file names a ROM is stored under on a device once downloaded, or under which a user's own copy of it would be indexed. It answers nil for a ROM whose files cannot be stored safely.

func NewLauncher

func NewLauncher(pl platforms.Platform) platforms.Launcher

NewLauncher builds the RomM launcher. It has no system of its own: its scanner runs for each system and lists the server's ROMs for it. Launching one downloads it into the system's game folder, where the system's own launcher starts it.

func NormalizeServerURL

func NormalizeServerURL(raw string) (string, error)

NormalizeServerURL turns a user-entered server address into the base URL requests are built from: an http or https URL with no query, fragment, credentials or trailing slash. An address without a scheme is taken as http, the way a RomM server on a home network is usually reached.

func ParseRomPath

func ParseRomPath(p string) (int, error)

ParseRomPath returns the ROM ID a romm:// path names.

func RomPath

func RomPath(id int, name string) string

RomPath is the virtual path a ROM is indexed under.

func Scan

func Scan(
	ctx context.Context,
	cfg *config.Instance,
	pl platforms.Platform,
	systemID string,
	results []platforms.ScanResult,
) ([]platforms.ScanResult, error)

Scan returns results with the server's ROMs for systemID added. ROMs the device already has a file of, by name, are left out, as are ROMs none of the system's launchers could open once downloaded.

func ServerSystems

func ServerSystems(ctx context.Context, c *Client) ([]string, error)

ServerSystems lists the Zaparoo systems the server has a platform for.

func ServerURL

func ServerURL(cfg *config.Instance) string

ServerURL returns the configured RomM server URL, or "" when none is set.

func SystemForPlatform

func SystemForPlatform(slug, fsSlug string) (string, bool)

SystemForPlatform returns the Zaparoo system a RomM platform's ROMs index under. The universal slug decides; the folder slug is a fallback for a custom platform RomM could not identify, matched against Zaparoo's own system IDs and aliases the way a folder name would be.

func Title

func Title(l Layout) string

Title is the name a ROM is indexed under: its file name without extension, the same name the file gets once downloaded, so filename tags such as region and revision parse the same way they do for local files.

Types

type Client

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

Client talks to one RomM server.

func ClientFromConfig

func ClientFromConfig(cfg *config.Instance) (*Client, error)

ClientFromConfig returns a client for the configured server, or ErrNotConfigured when there is none.

func NewClient

func NewClient(serverURL string) (*Client, error)

NewClient returns a client for the server at serverURL.

func (*Client) AssetURL

func (c *Client) AssetURL(assetPath string) (string, bool)

AssetURL resolves a cover or screenshot path from the API against the server. Only server-relative paths are accepted: an absolute URL points at some other host, which Core does not fetch from.

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL is the server URL requests are built from.

func (*Client) ContentURL

func (c *Client) ContentURL(id int, fileName string) string

ContentURL is where the ROM's files download from. fileName names the download: a multi-file ROM arrives as <fileName>.zip with a generated <fileName>.m3u inside when the server builds a playlist.

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, rawURL string, limit int64) ([]byte, error)

Fetch downloads an asset URL from this server, up to limit bytes.

func (*Client) Platforms

func (c *Client) Platforms(ctx context.Context) ([]Platform, error)

Platforms lists the server's platforms.

func (*Client) PollDeviceToken

func (c *Client) PollDeviceToken(ctx context.Context, deviceCode string) (string, error)

PollDeviceToken asks once whether a link was approved, and returns the access token when it was. A request still waiting answers ErrLinkPending or ErrLinkSlowDown; ErrLinkDenied and ErrLinkExpired end the flow.

func (*Client) Rom

func (c *Client) Rom(ctx context.Context, id int) (*Rom, error)

Rom fetches one ROM.

func (*Client) Roms

func (c *Client) Roms(ctx context.Context, platformID int) ([]Rom, error)

Roms lists every ROM on one platform, following pages.

func (c *Client) StartDeviceLink(ctx context.Context, req DeviceLinkRequest) (*DeviceLink, error)

StartDeviceLink asks the server to start a device link. The user approves it in RomM's web interface, after which PollDeviceToken returns the token.

type DeviceLink struct {
	DeviceCode              string
	UserCode                string
	VerificationURL         string
	VerificationURLComplete string
	ExpiresIn               int
	Interval                int
}

DeviceLink is a started link request. VerificationURL and VerificationURLComplete are absolute, under the server's URL.

type DeviceLinkRequest

type DeviceLinkRequest struct {
	Identifier string
	Name       string
	Platform   string
	Version    string
}

DeviceLinkRequest describes the device asking to be linked.

type Layout

type Layout struct {
	// Name is the file a single-file ROM is saved as, or the folder a
	// multi-file ROM is unpacked into.
	Name string
	// Archive marks a multi-file ROM, which RomM serves as one zip.
	Archive bool
}

Layout is how a ROM is stored on the device.

func LayoutFor

func LayoutFor(rom *Rom) (Layout, error)

LayoutFor works out where a ROM goes on the device. A single-file ROM keeps its file's own name: for a ROM nested in a folder on the server, fs_name is that folder, not the file. A multi-file ROM is named after the ROM without its extension, which is also the name RomM gives a generated .m3u.

type Metadatum

type Metadatum struct {
	AverageRating    *float64 `json:"average_rating"`
	FirstReleaseDate *int64   `json:"first_release_date"`
	PlayerCount      string   `json:"player_count"`
	Genres           []string `json:"genres"`
	Franchises       []string `json:"franchises"`
	Companies        []string `json:"companies"`
	Publishers       []string `json:"publishers"`
	Developers       []string `json:"developers"`
	GameModes        []string `json:"game_modes"`
	AgeRatings       []string `json:"age_ratings"`
}

Metadatum is RomM's merged metadata for a ROM, drawn from whichever metadata providers the server has enabled.

type Platform

type Platform struct {
	Slug      string `json:"slug"`
	FSSlug    string `json:"fs_slug"`
	Name      string `json:"name"`
	UpdatedAt string `json:"updated_at"`
	ID        int    `json:"id"`
	ROMCount  int    `json:"rom_count"`
}

Platform is one entry of GET /api/platforms.

type Rom

type Rom struct {
	Metadatum         Metadatum `json:"metadatum"`
	HasFileOnDisk     *bool     `json:"has_file_on_disk"`
	PlatformSlug      string    `json:"platform_slug"`
	PlatformFSSlug    string    `json:"platform_fs_slug"`
	FSName            string    `json:"fs_name"`
	FSNameNoTags      string    `json:"fs_name_no_tags"`
	FSNameNoExt       string    `json:"fs_name_no_ext"`
	FSExtension       string    `json:"fs_extension"`
	Name              string    `json:"name"`
	Summary           string    `json:"summary"`
	PathCoverLarge    string    `json:"path_cover_large"`
	PathCoverSmall    string    `json:"path_cover_small"`
	UpdatedAt         string    `json:"updated_at"`
	Regions           []string  `json:"regions"`
	Languages         []string  `json:"languages"`
	MergedScreenshots []string  `json:"merged_screenshots"`
	Files             []RomFile `json:"files"`
	ID                int       `json:"id"`
	PlatformID        int       `json:"platform_id"`
	FSSizeBytes       int64     `json:"fs_size_bytes"`
	HasMultipleFiles  bool      `json:"has_multiple_files"`
	MissingFromFS     bool      `json:"missing_from_fs"`
}

Rom is one ROM as returned by the ROM list and detail endpoints. Only the fields Core uses are decoded.

func SystemRoms

func SystemRoms(ctx context.Context, c *Client, systemID string) ([]Rom, error)

SystemRoms lists every ROM the server files under platforms that map to systemID. A system no platform maps to has none, and is not an error.

func (*Rom) Downloadable

func (r *Rom) Downloadable() bool

Downloadable reports whether the server has the ROM's files to serve.

type RomFile

type RomFile struct {
	FileName      string `json:"file_name"`
	FilePath      string `json:"file_path"`
	ID            int    `json:"id"`
	FileSizeBytes int64  `json:"file_size_bytes"`
}

RomFile is one file belonging to a ROM.

Jump to

Keyboard shortcuts

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