animemap

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package animemap maps TMDB and TVDB titles to the anime databases (Kitsu, MyAnimeList, AniList, AniDB) whose ids anime-only Stremio addons and SeaDex look titles up by.

The primary mapping is Fribb/anime-lists on GitHub, supplemented by Anime-Lists/anime-lists (XML) and anime-offline-database (JSON) to fill missing IDs and unmapped titles/seasons ("Fribb wins, others fill gaps"). Datasets are read lazily at runtime only when needed; Ether ships no copy. All inputs are untrusted: downloads are size- and time-bounded, failures back off, and any ambiguity yields no mapping rather than a guess.

Index

Constants

View Source
const (
	DefaultURL                = "https://raw.githubusercontent.com/Fribb/anime-lists/master/anime-list-mini.json"
	DefaultAnimeListsURL      = "https://raw.githubusercontent.com/Anime-Lists/anime-lists/master/anime-list-full.xml"
	DefaultOfflineDatabaseURL = "https://github.com/manami-project/anime-offline-database/releases/latest/download/anime-offline-database-minified.json"
)

Default dataset URLs read when Options.URL is empty.

View Source
const (
	Kitsu   = "kitsu"
	MAL     = "mal"
	AniList = "anilist"
	AniDB   = "anidb"
)

Databases an anime addon or ranking source may look titles up by.

Variables

View Source
var ErrUnavailable = errors.New("animemap: anime id mapping unavailable")

ErrUnavailable reports that the dataset could not be loaded (or is backing off after a failure). Callers treat it as "no mapping".

Functions

This section is empty.

Types

type Options

type Options struct {
	URL                string       // "" = DefaultURL
	AnimeListsURL      string       // "" = DefaultAnimeListsURL when URL is ""
	OfflineDatabaseURL string       // "" = DefaultOfflineDatabaseURL when URL is ""
	CacheDir           string       // "" = memory cache only
	Client             *http.Client // nil = a public-only safefetch client
	Logger             *slog.Logger
	Now                func() time.Time
	TTL                time.Duration // 0 = 24h
	MaxBytes           int64         // 0 = 96 MiB
	Timeout            time.Duration // 0 = 90s
}

Options configure a Service.

type Service

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

Service loads the datasets lazily and answers lookups from memory (backed by an optional durable cache in Options.CacheDir).

func New

func New(opts Options) *Service

New returns a Service; nothing is fetched until the first lookup.

func (*Service) Lookup

func (s *Service) Lookup(ctx context.Context, req core.SearchRequest, db string) (id int64, episode int, ok bool, err error)

Lookup maps a search request to db's id and, for an episode, the episode's number inside that entry. ok is false when the request has no unambiguous mapping. err is non-nil only when the dataset is unavailable.

func (*Service) LookupCached

func (s *Service) LookupCached(req core.SearchRequest, db string) (id int64, episode int, ok bool)

LookupCached answers from the in-memory index or the durable local disk cache (even if past TTL) without ever performing network I/O.

func (*Service) LookupCour

func (s *Service) LookupCour(ctx context.Context, req core.SearchRequest) (core.CourMapping, bool, error)

LookupCour maps an offset TMDB anime season episode to its 1-based cour (part) number within that season, its 1-based episode inside that cour, and its anime-lists TVDB season/episode numbering when present.

Jump to

Keyboard shortcuts

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