coverage

package
v0.8.0-dev.6 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package coverage provides pure computation functions for subtitle coverage analysis. These functions have no dependency on the server package or HTTP handling — they operate solely on api types.

Index

Constants

View Source
const RuleDefault = "default"

RuleDefault is the rule name shown when no audio language rule matches.

View Source
const RuleNoTargets = "no targets"

RuleNoTargets is the rule name shown when no subtitle targets are configured.

Variables

This section is empty.

Functions

func CountMissing

func CountMissing(ctx context.Context, cfg CountCfg, db FileReader, allSeries []arrapi.Series, allMovies []arrapi.Movie) int

CountMissing returns the total number of missing subtitle targets across all series and movies.

func CountMissingMovies

func CountMissingMovies(ctx context.Context, cfg CountCfg, db FileReader, allMovies []arrapi.Movie, ignoredCodecs map[string]bool) int

CountMissingMovies returns the number of missing subtitle targets for movies.

func CountMissingSeries

func CountMissingSeries(ctx context.Context, cfg CountCfg, db FileReader, allSeries []arrapi.Series, ignoredCodecs map[string]bool) int

CountMissingSeries returns the number of missing subtitle targets for series.

func DeduplicateFileRows

func DeduplicateFileRows(rows []subflux.SubtitleEntry) []subflux.SubtitleEntry

DeduplicateFileRows collapses multiple rows with the same (media_id, language, variant, source) into one row for display.

func ExtractSeriesPrefix

func ExtractSeriesPrefix(epMediaID string) string

ExtractSeriesPrefix extracts the series prefix from an episode media ID. Episode IDs are "{prefix}s{ss}e{ee}" (e.g. "tvdb-12345-s01e01"). Returns the prefix including the trailing "-", or "" if the format is unrecognized.

func IndexSubStatus

func IndexSubStatus(files []subflux.SubtitleEntry, ignoredCodecs map[string]bool) map[string]map[Key]*Status

IndexSubStatus builds a media_id → Key → Status index from subtitle file rows. A subtitle is "usable" if it's external or embedded with a non-ignored codec.

func ResolveRuleName

func ResolveRuleName(audioLang string, targets []subflux.SubtitleTarget) string

ResolveRuleName returns the display rule name for coverage based on the audio language and resolved targets.

Types

type CountCfg added in v0.4.0

type CountCfg interface {
	ResolveTargetsWithFallback(originalLang string, audioLangs []string) []subflux.SubtitleTarget
	EmbeddedPolicy() subflux.EmbeddedPolicy
}

CountCfg is what the missing-count pass reads out of the configuration: the language targets a media item earns, and the embedded-codec policy that decides which existing tracks count as usable. 2 of the 37 values the config offers — counting is arithmetic over targets and rows, so it asks nothing about providers, scoring, paths or the server runtime.

Exported because queryhandlers names it: the CountMissing function value the composition root binds and hands over takes this as its parameter, and naming this type is what keeps that signature from drifting back to a wider one.

type FileReader added in v0.4.0

type FileReader interface {
	SubtitleFiles(ctx context.Context, mediaType subflux.MediaType, mediaIDPrefix string) ([]subflux.SubtitleEntry, error)
}

FileReader is the ONE thing the missing-count pass asks of the store: read every subtitle-file row for a media type, once per type, and count against it in memory. One of the twelve methods the coverage surface offers — this pass records nothing, stamps nothing, and never reads scan state.

Exported because queryhandlers names it: the CountMissing function value it is handed takes this as a parameter, and naming this type is what keeps that signature from drifting into a wider one.

type Key

type Key struct{ Lang, Variant string }

Key identifies a subtitle by language and variant for coverage indexing.

type Status

type Status struct{ Usable, IgnoredOnly bool }

Status tracks whether a media item has a usable subtitle or only ignored-codec embedded subs for a given language+variant.

type TargetCoverage

type TargetCoverage struct {
	Language    string `json:"language"`
	Variant     string `json:"variant"`
	Have        int    `json:"have"`
	HaveIgnored int    `json:"have_ignored"`
	Total       int    `json:"total"`
}

TargetCoverage tracks coverage for a single expected subtitle target.

func CountEpisodesGrouped added in v0.4.0

func CountEpisodesGrouped(
	episodes []map[Key]*Status,
	targets []subflux.SubtitleTarget,
	total int,
) []TargetCoverage

CountEpisodesGrouped counts coverage from pre-grouped episode subtitle maps.

func CountMovies added in v0.4.0

func CountMovies(
	subs map[Key]*Status,
	targets []subflux.SubtitleTarget,
) []TargetCoverage

CountMovies returns target coverage for a single movie.

Jump to

Keyboard shortcuts

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