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
- Variables
- type Options
- type Service
- func (s *Service) Lookup(ctx context.Context, req core.SearchRequest, db string) (id int64, episode int, ok bool, err error)
- func (s *Service) LookupCached(req core.SearchRequest, db string) (id int64, episode int, ok bool)
- func (s *Service) LookupCour(ctx context.Context, req core.SearchRequest) (core.CourMapping, bool, error)
Constants ¶
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.
const ( Kitsu = "kitsu" MAL = "mal" AniList = "anilist" AniDB = "anidb" )
Databases an anime addon or ranking source may look titles up by.
Variables ¶
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 (*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 ¶
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.