scoring

package
v0.1.120 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: GPL-2.0, GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package scoring provides pure subtitle scoring and identity filtering.

Index

Constants

This section is empty.

Variables

View Source
var (
	SeasonEpRe   = regexp.MustCompile(`(?i)S\d{1,2}E\d{1,3}`)
	SeasonOnlyRe = regexp.MustCompile(`(?i)S(\d{1,2})(?:E\d{1,3})?`)
)

SeasonEpRe matches S##E## episode markers in release names (e.g. S01E03).

Functions

func AnyReleaseNameMatches

func AnyReleaseNameMatches(req *api.SearchRequest, releaseName string) bool

AnyReleaseNameMatches reports whether releaseName contains any of the request's titles (primary or alternatives) after stripping release group tags.

func AnyTitleMatches

func AnyTitleMatches(req *api.SearchRequest, candidate string) bool

AnyTitleMatches reports whether candidate matches the primary title or any alternative title in the request after normalization.

func BuildMatches

func BuildMatches(video *api.VideoInfo, sub *api.Subtitle, deps MatchDeps) api.MatchSet

BuildMatches compares video and subtitle release attributes, returning a set of matched attribute keys used by the scorer.

func EpisodeNumberMatch

func EpisodeNumberMatch(subSeason, subEpisode int, req *api.SearchRequest) bool

EpisodeNumberMatch reports whether the subtitle's season/episode pair matches the request, including scene and absolute episode numbering alternatives.

func ExtractReleaseSeason

func ExtractReleaseSeason(releaseName string) int

ExtractReleaseSeason extracts the season number from a release name via the S##E## or S## pattern. Returns 0 if no season marker is found.

func FilterByIdentity

func FilterByIdentity(results []api.Subtitle, req *api.SearchRequest) (kept []api.Subtitle, dropped int)

FilterByIdentity drops results that don't match the requested season/episode or show title. Returns the kept results and the number of dropped results so the caller can log as appropriate.

func IdentityOK

func IdentityOK(sub *api.Subtitle, req *api.SearchRequest) bool

IdentityOK reports whether a subtitle passes the identity check for the given request. Hash-matched subtitles always pass. Subtitles with season/episode metadata are validated against the request's expected episode and title.

func IdentityTitleOK

func IdentityTitleOK(sub *api.Subtitle, req *api.SearchRequest) bool

IdentityTitleOK reports whether the subtitle's title metadata is consistent with the search request. Subtitles matched by a stable ID (TVDB, IMDB, hash) skip title validation; title-matched subtitles must pass AnyTitleMatches.

func IsSeasonPack

func IsSeasonPack(releaseName string) bool

IsSeasonPack returns true if the release name looks like a season pack.

func MatchBreakdown

func MatchBreakdown(scores *api.Scores, matches api.MatchSet) map[string]int

MatchBreakdown returns the per-category score contributions for a match set.

func NormalizeTitle

func NormalizeTitle(s string) string

NormalizeTitle lowercases and replaces common separators with spaces.

func ReleaseNameMatchesTitle

func ReleaseNameMatchesTitle(reqTitle, releaseName string) bool

ReleaseNameMatchesTitle checks if a release name's title portion matches the requested title.

func TitlesMatch

func TitlesMatch(requested, candidate string) bool

TitlesMatch compares two titles after normalization.

Types

type MatchDeps

type MatchDeps struct {
	ParseRelease  func(string) ReleaseInfo
	CompareSource func(*api.MatchSet, string, string)
	IsSeasonPack  func(string) bool
}

MatchDeps provides release-parsing dependencies to BuildMatches.

type ReleaseInfo

type ReleaseInfo struct {
	Source           string
	VideoCodec       string
	ReleaseGroup     string
	StreamingService string
	Edition          string
	HDR              string
}

ReleaseInfo holds metadata extracted from a release/scene name.

Jump to

Keyboard shortcuts

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