coverage

package
v0.1.147 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: GPL-2.0, GPL-3.0 Imports: 5 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 api.ConfigProvider, db api.CoverageStore, 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 api.ConfigProvider, db api.CoverageStore, 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 api.ConfigProvider, db api.CoverageStore, allSeries []arrapi.Series, ignoredCodecs map[string]bool) int

CountMissingSeries returns the number of missing subtitle targets for series.

func DeduplicateFileRows

func DeduplicateFileRows(rows []api.SubtitleEntry) []api.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 []api.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 []api.SubtitleTarget) string

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

Types

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 CountEpisodeCoverageGrouped

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

CountEpisodeCoverageGrouped counts coverage from pre-grouped episode subtitle maps.

func CountMovieCoverage

func CountMovieCoverage(
	subs map[Key]*Status,
	targets []api.SubtitleTarget,
) []TargetCoverage

CountMovieCoverage 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