sources

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sources holds the runtime registry of indexer endpoints.

The registry is loaded at startup from one of:

  1. LIBRARR_SOURCES_PATH — local JSON file (takes precedence)
  2. LIBRARR_SOURCES_URL — HTTP(S) URL to a JSON file
  3. embedded defaults — fallback if neither is set or both fail to load

Legacy per-source environment variables (ANNAS_ARCHIVE_DOMAIN, etc.) still take precedence over the registry value when they are set.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnasSpec

type AnnasSpec struct {
	Domain string `json:"domain"`
}

AnnasSpec is the configurable endpoint for an Anna's-Archive-style direct-download driver.

type AudioBookBaySpec

type AudioBookBaySpec struct {
	Mirrors  []string `json:"mirrors"`
	Trackers []string `json:"trackers"`
}

AudioBookBaySpec is the mirror + tracker list for an AudioBookBay-style scrape driver.

type MangaDexSpec

type MangaDexSpec struct {
	APIURL     string `json:"api_url"`
	UploadsURL string `json:"uploads_url"`
	WebURL     string `json:"web_url"`
}

MangaDexSpec carries the three independent endpoints used by the MangaDex driver.

type OpenLibrarySpec

type OpenLibrarySpec struct {
	SearchURL string `json:"search_url"`
	CoverURL  string `json:"cover_url"`
}

OpenLibrarySpec splits search and cover endpoints for the Open Library driver.

type Registry

type Registry struct {
	Version         int              `json:"version"`
	Annas           AnnasSpec        `json:"annas"`
	AudioBookBay    AudioBookBaySpec `json:"audiobookbay"`
	ThePirateBay    URLSpec          `json:"thepiratebay"`
	Gutenberg       URLSpec          `json:"gutenberg"`
	OpenLibrary     OpenLibrarySpec  `json:"openlibrary"`
	Librivox        URLSpec          `json:"librivox"`
	StandardEbooks  URLSpec          `json:"standardebooks"`
	MangaDex        MangaDexSpec     `json:"mangadex"`
	Nyaa            URLSpec          `json:"nyaa"`
	WebNovels       []WebNovelSite   `json:"webnovels"`
	LibgenMirrors   []string         `json:"libgen_mirrors"`
	ZLibraryDefault string           `json:"zlibrary_default"`
}

Registry is the in-memory representation of the indexer registry.

func Default

func Default() (*Registry, error)

Default returns the embedded fallback registry. Used when no external source is configured or when fetching fails.

func Load

func Load(path, url string) *Registry

Load resolves the active registry from (in order): a local file path, an HTTP URL, or the embedded defaults. Any error fetching/parsing an external source is logged and the embedded defaults are returned so the binary never fails to start over a missing registry.

path takes precedence over url. Both arguments may be empty.

func (*Registry) ApplyEnvOverrides

func (r *Registry) ApplyEnvOverrides(getenv func(string) string) *Registry

ApplyEnvOverrides patches the registry with any legacy per-source environment variables that are set. Returns the (mutated) input registry for chaining. This preserves backwards compatibility for users who configure individual endpoints via env vars instead of editing the registry.

func (*Registry) WebNovel

func (r *Registry) WebNovel(id string) *WebNovelSite

WebNovel looks up a configured web-novel site by ID. Returns nil if absent.

type URLSpec

type URLSpec struct {
	URL string `json:"url"`
}

URLSpec is a single-URL driver endpoint.

type WebNovelSite

type WebNovelSite struct {
	ID      string `json:"id"`
	Label   string `json:"label"`
	URL     string `json:"url"`
	BaseURL string `json:"base_url,omitempty"`
}

WebNovelSite is one entry in the web-novel driver's site table.

Jump to

Keyboard shortcuts

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