sources

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 10 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. The built-in default URL (the librarr-sources companion repo)
  4. On-disk cache of the last successful fetch

The production binary ships no embedded registry — Librarr matches the Prowlarr pattern of fetching its indexer definitions at runtime. The on-disk cache lets subsequent restarts work even if the network is down.

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

func NormalizeDomain added in v1.2.0

func NormalizeDomain(value string) string

NormalizeDomain accepts either a hostname or URL and returns only the host. Source drivers that consume domain fields add their own scheme and paths.

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 Load

func Load(path, url, cachePath string) *Registry

Load resolves the active registry in this order:

  1. path — local JSON file (LIBRARR_SOURCES_PATH)
  2. url — user-supplied HTTP(S) URL (LIBRARR_SOURCES_URL)
  3. The built-in default URL (librarr-sources)
  4. cachePath — on-disk copy of the last successful fetch

On a successful HTTP fetch (steps 2 or 3) the body is written to cachePath so subsequent restarts work offline. If every step fails the function returns a non-nil empty Registry — callers can still range over slices, but search will return no results until the registry can be reached.

All inputs 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) Normalize added in v1.2.0

func (r *Registry) Normalize() *Registry

Normalize canonicalizes host-only fields after any registry or env load.

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.

Directories

Path Synopsis
Package sourcestest is a test-only helper that exposes the canonical librarr-sources registry as Go bytes/types.
Package sourcestest is a test-only helper that exposes the canonical librarr-sources registry as Go bytes/types.

Jump to

Keyboard shortcuts

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