Documentation
¶
Index ¶
Constants ¶
const DefaultScanInterval = Interval(5 * time.Second)
DefaultScanInterval is the duration between directory scans when none is specified in the config.
Variables ¶
This section is empty.
Functions ¶
func NewValidator ¶
NewValidator returns a validator configured with the mediatype validator and with runtime length-constraint rules derived from `jsonschema:"minLength=N"` tags on the watcher config struct types.
Types ¶
type CompiledRegexp ¶
CompiledRegexp is a Go regular expression that is compiled at YAML parse time. An invalid expression causes YAML unmarshaling (and therefore config loading) to fail with a descriptive error, so no separate validation step is required.
func (CompiledRegexp) JSONSchema ¶
func (CompiledRegexp) JSONSchema() *jsonschema.Schema
JSONSchema returns a JSON Schema for CompiledRegexp. The type serialises as a scalar string (the regex pattern) at YAML parse time; reflecting the Go struct would produce an empty object schema, so this method overrides that to describe the on-disk shape accurately.
func (*CompiledRegexp) UnmarshalYAML ¶
func (c *CompiledRegexp) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML compiles the scalar YAML string as a Go regular expression. It returns an error if the node is not a scalar string, if the string is empty, or if the expression is invalid.
type Config ¶
type Config struct {
// ScanInterval controls how often the watcher walks each configured watch directory.
// Specified as a Go duration string (e.g. "5s", "1m30s"). Defaults to 5 seconds when omitted.
ScanInterval Interval `yaml:"scanInterval,omitempty" validate:"gt=0"`
// Watches lists the directories to monitor and their associated media types.
Watches []WatchEntry `yaml:"watches,omitempty" validate:"dive"`
}
Config is the top-level watcher configuration loaded from the YAML config file.
func (*Config) SetDefaults ¶
func (cfg *Config) SetDefaults()
SetDefaults implements defaults.Setter to initialize Config fields from package constants, avoiding duplicate literal values in struct tags.
type Interval ¶ added in v0.0.6
Interval is a Go duration parsed from a YAML scalar like "5s" or "1m30s". It exists because yaml.v3 does not natively understand time.Duration values.
func (Interval) Duration ¶ added in v0.0.6
Duration returns the interval as a time.Duration for use with time.NewTicker etc.
func (Interval) JSONSchema ¶ added in v0.0.6
func (Interval) JSONSchema() *jsonschema.Schema
JSONSchema returns a JSON Schema describing the on-disk shape of Interval (a duration string).
func (Interval) MarshalYAML ¶ added in v0.0.6
MarshalYAML emits the interval as its canonical Go duration string.
type WatchEntry ¶
type WatchEntry struct {
// Name is a human-readable label for this watch entry, used in logs and metrics.
Name string `yaml:"name" jsonschema:"minLength=1"`
// Input describes the directory the watcher scans for media files.
Input WatchEntryInput `yaml:"input"`
// MediaType indicates whether this directory contains movies or TV show episodes.
MediaType medialib.MediaType `yaml:"mediaType" validate:"mediatype"`
// IgnorePatterns is an optional list of Go regular expressions matched against the absolute
// path of each file and directory encountered during a scan. A matching file is silently
// skipped; a matching directory causes its entire subtree to be pruned. Patterns are
// compiled when the configuration is loaded; an invalid expression causes configuration loading to fail.
IgnorePatterns []CompiledRegexp `yaml:"ignorePatterns,omitempty" validate:"omitempty"`
// PreserveSource controls whether the source file is deleted after successful processing.
// When true, the source file is kept; when false or omitted, the source file is deleted
// (default behaviour).
PreserveSource bool `yaml:"preserveSource,omitempty"`
// RetainEmptyDirectories controls whether empty parent directories are removed after the
// source file is deleted. When false or omitted (the default), parent directories that
// become empty as a result of source-file deletion are pruned bottom-up, stopping at the
// watch root. When true, no directory removal is performed.
RetainEmptyDirectories bool `yaml:"retainEmptyDirectories,omitempty"`
// Output describes where processed files are written and how the output path is translated
// for the arr service.
Output WatchEntryOutput `yaml:"output"`
}
WatchEntry describes a watched location, mapping a filesystem path to a media type for dispatch and carrying a human-readable name for identification.
type WatchEntryInput ¶ added in v0.0.20
type WatchEntryInput struct {
// Path is the filesystem path to the directory the watcher scans. Relative paths are
// resolved against the watcher's working directory.
Path string `yaml:"path" jsonschema:"minLength=1"`
}
WatchEntryInput describes the input source for a watch entry.
type WatchEntryOutput ¶ added in v0.0.3
type WatchEntryOutput struct {
// Path is the filesystem path to the directory where processed files are written.
Path string `yaml:"path" jsonschema:"minLength=1"`
// RemotePath is the path by which the output directory is known to the arr service (Radarr/Sonarr).
// Set this when the worker and the arr service mount the output volume at different paths.
// When empty, no path translation is applied.
RemotePath string `yaml:"remotePath,omitempty"`
}
WatchEntryOutput describes the output destination for a watch entry.