Documentation
¶
Overview ¶
Package libraryfilter evaluates owner catalogue visibility rules without network access. The same compiled conditions drive local previews and every client. Rules run top to bottom and the first match wins. An empty action is hide, and an empty default is show, so a saved exclusion list hides the same titles as before.
These helpers support offline acceptance tests across package boundaries. Runtime callers use the production APIs in the other files.
Index ¶
- func CountryAliases(v string) []string
- type Filter
- func (f *Filter) CatchCountsSQL() (string, []any)
- func (f *Filter) Decidable(t *core.Title) bool
- func (f *Filter) Facts() core.TitleFacts
- func (f *Filter) Fallback() string
- func (f *Filter) ForSearch() *Filter
- func (f *Filter) Hidden(t *core.Title) bool
- func (f *Filter) Passive() bool
- func (f *Filter) SQLHidden() (string, []any)
- func (f *Filter) SQLHiddenForType(typ core.MediaType) (string, []any)
- func (f *Filter) SQLUndecidable() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountryAliases ¶
TMDB movie production countries use names; TV origins use ISO codes. Match both forms, never infer a country from the spoken language.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
func Compile ¶
func Compile(specs []core.LibraryExclusion) (*Filter, error)
Compile treats every rule as hide and leaves unmatched titles visible.
func CompilePolicy ¶ added in v0.3.0
func CompilePolicy(specs []core.LibraryExclusion, fallback string) (*Filter, error)
CompilePolicy compiles ordered rules. fallback is "show" or "hide" for titles that match nothing; empty means show.
func (*Filter) CatchCountsSQL ¶ added in v0.3.0
CatchCountsSQL returns one movie count and one show count per rule, in order. A title is counted on the first rule it matches.
func (*Filter) Decidable ¶
Decidable reports whether every condition of every hide rule that applies to t's type can be judged from t's own fields. A condition on an unknown field (no certification, countries, genres...) answers "no match", so a hide rule silently lets such a title through. An unknown field in a show rule can only make a title hidden, never shown, so show rules don't count. Callers that must fail closed (a restricted viewer's rules on a summary the catalogue has no details for) drop titles that are not decidable. Known/unknown conditions and vote counts (0 is a real value) are always decidable.
func (*Filter) Facts ¶
func (f *Filter) Facts() core.TitleFacts
Facts reports the facts outside a title's row that the rules read (core.TitleFacts): genres, studios and networks, countries, keywords. Every other condition is on the row itself.
func (*Filter) ForSearch ¶ added in v0.3.2
ForSearch returns the filter explicit searches use: the same rules without the ones scoped to discovery. Only hide rules carry that scope, so a title visible while browsing is never hidden from search. Compile it once per config change; it shares the compiled conditions.
func (*Filter) SQLHidden ¶
SQLHidden returns a parameterized predicate for catalog_titles AS t. Hide-only rules with a show default stay an OR, which is the same predicate as first-match. A show rule or a hide default compiles to a CASE so the first match wins.
func (*Filter) SQLHiddenForType ¶ added in v0.3.4
SQLHiddenForType specializes the policy for a known media type. This retains first-match ordering while dropping rules for other media types.
func (*Filter) SQLUndecidable ¶
SQLUndecidable is Decidable's complement for catalog_titles AS t: true when some condition of an applicable hide rule is on a field the row does not know. "0=1" when every row is decidable.