Documentation
¶
Overview ¶
Package scoring holds the pure matching and weighting rules the scan engine applies to a candidate: which subtitles identify as the requested item, which weight categories a release hits, and the title and episode comparisons under both.
Its heaviest consumer by far is internal/search, which is why it sits here rather than at the top level. internal/scorer is the configured engine over these rules and uses exactly one symbol from this package; see its doc for why the two stay apart despite the near-identical names.
Index ¶
- Variables
- func AnyReleaseNameMatches(req *subflux.SearchRequest, releaseName string) bool
- func AnyTitleMatches(req *subflux.SearchRequest, candidate string) bool
- func BuildMatches(video *subflux.VideoInfo, sub *subflux.Subtitle, deps MatchDeps) subflux.MatchSet
- func EpisodeNumberMatch(subSeason, subEpisode int, req *subflux.SearchRequest) bool
- func ExtractReleaseSeason(releaseName string) int
- func FilterByIdentity(results []subflux.Subtitle, req *subflux.SearchRequest) (kept []subflux.Subtitle, dropped int)
- func IdentityOK(sub *subflux.Subtitle, req *subflux.SearchRequest) bool
- func IdentityTitleOK(sub *subflux.Subtitle, req *subflux.SearchRequest) bool
- func IsSeasonPack(releaseName string) bool
- func MatchBreakdown(scores *subflux.Scores, matches subflux.MatchSet) map[string]int
- func NormalizeTitle(s string) string
- func TitlesMatch(requested, candidate string) bool
- type MatchDeps
- type ReleaseInfo
Constants ¶
This section is empty.
Variables ¶
var Categories = []category{ { Key: "source", Weight: func(s *subflux.Scores) int { return s.Source }, Match: func(m subflux.MatchSet) bool { return m.Source }, SetMatch: func(m *subflux.MatchSet) { m.Source = true }, }, { Key: "release_group", Weight: func(s *subflux.Scores) int { return s.ReleaseGroup }, Match: func(m subflux.MatchSet) bool { return m.ReleaseGroup }, SetMatch: func(m *subflux.MatchSet) { m.ReleaseGroup = true }, Extract: func(r ReleaseInfo) string { return r.ReleaseGroup }, }, { Key: "streaming_service", Weight: func(s *subflux.Scores) int { return s.StreamingService }, Match: func(m subflux.MatchSet) bool { return m.StreamingService }, SetMatch: func(m *subflux.MatchSet) { m.StreamingService = true }, Extract: func(r ReleaseInfo) string { return r.StreamingService }, }, { Key: "video_codec", Weight: func(s *subflux.Scores) int { return s.VideoCodec }, Match: func(m subflux.MatchSet) bool { return m.VideoCodec }, SetMatch: func(m *subflux.MatchSet) { m.VideoCodec = true }, Extract: func(r ReleaseInfo) string { return r.VideoCodec }, }, { Key: "hdr", Weight: func(s *subflux.Scores) int { return s.HDR }, Match: func(m subflux.MatchSet) bool { return m.HDR }, SetMatch: func(m *subflux.MatchSet) { m.HDR = true }, Extract: func(r ReleaseInfo) string { return r.HDR }, }, { Key: "edition", Weight: func(s *subflux.Scores) int { return s.Edition }, Match: func(m subflux.MatchSet) bool { return m.Edition }, SetMatch: func(m *subflux.MatchSet) { m.Edition = true }, Extract: func(r ReleaseInfo) string { return r.Edition }, }, { Key: "season_pack", Weight: func(s *subflux.Scores) int { return s.SeasonPack }, Match: func(m subflux.MatchSet) bool { return m.SeasonPack }, SetMatch: func(m *subflux.MatchSet) { m.SeasonPack = true }, }, }
Categories is the canonical table of scored release-attribute categories, shared by the match builder (BuildMatches), the score breakdown (MatchBreakdown), and the scorer (internal/scorer). Hash and identity (IMDB) matching are handled separately by each consumer. Adding a scoring category is a one-entry change here, plus the subflux.Scores/subflux.MatchSet fields it references.
Functions ¶
func AnyReleaseNameMatches ¶
func AnyReleaseNameMatches(req *subflux.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 *subflux.SearchRequest, candidate string) bool
AnyTitleMatches reports whether candidate matches the primary title or any alternative title in the request after normalization.
func BuildMatches ¶
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 *subflux.SearchRequest) bool
EpisodeNumberMatch reports whether the subtitle's season/episode pair matches the request, including scene and absolute episode numbering alternatives.
func ExtractReleaseSeason ¶
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 []subflux.Subtitle, req *subflux.SearchRequest) (kept []subflux.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 *subflux.Subtitle, req *subflux.SearchRequest) bool
IdentityOK reports whether a subtitle passes the identity check for the given request. Hash-matched subtitles always pass. A release name that names only other episodes fails whatever the subtitle's metadata says, because some providers copy the request's season and episode onto every result. Subtitles with season/episode metadata are validated against the request's expected episode and title.
func IdentityTitleOK ¶
func IdentityTitleOK(sub *subflux.Subtitle, req *subflux.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 ¶
IsSeasonPack returns true if the release name looks like a season pack: it carries a readable season marker and no episode marker at all.
func MatchBreakdown ¶
MatchBreakdown returns the per-category score contributions for a match set.
func NormalizeTitle ¶
NormalizeTitle lowercases and replaces common separators with spaces.
func TitlesMatch ¶
TitlesMatch compares two titles after normalization.