config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigDir

func GetConfigDir() string

GetConfigDir returns the config directory path (exported version)

func InitLogger

func InitLogger(cfg *LoggingConfig) (*slog.Logger, error)

InitLogger initializes the application logger based on configuration

func InitializeDirs

func InitializeDirs() error

InitializeDirs creates all required greg directories if they don't exist

func SaveDefaultConfig

func SaveDefaultConfig(configPath string) error

SaveDefaultConfig saves the default configuration to a file

func SetDefaults

func SetDefaults(v *viper.Viper)

SetDefaults sets default configuration values This function is exported for use in other packages

Types

type APIConfig

type APIConfig struct {
	BaseURL string        `mapstructure:"base_url"`
	Timeout time.Duration `mapstructure:"timeout"`
}

APIConfig contains API server settings

type AdvancedConfig

type AdvancedConfig struct {
	Experimental  bool            `mapstructure:"experimental"`
	Debug         bool            `mapstructure:"debug"`
	NoTelemetry   bool            `mapstructure:"no_telemetry"`
	Profiling     []string        `mapstructure:"profiling"`
	MaxGoroutines int             `mapstructure:"max_goroutines"`
	Clipboard     ClipboardConfig `mapstructure:"clipboard"`
}

AdvancedConfig contains advanced settings

type AniListConfig

type AniListConfig struct {
	Enabled       bool          `mapstructure:"enabled"`
	AutoSync      bool          `mapstructure:"auto_sync"`
	SyncThreshold float64       `mapstructure:"sync_threshold"`
	AutoComplete  bool          `mapstructure:"auto_complete"`
	SyncInterval  time.Duration `mapstructure:"sync_interval"`
	RedirectURI   string        `mapstructure:"redirect_uri"`
	ServerPort    int           `mapstructure:"server_port"`
}

AniListConfig contains AniList-specific settings

type CacheConfig

type CacheConfig struct {
	Enabled       bool     `mapstructure:"enabled"`
	Path          string   `mapstructure:"path"`
	TTL           CacheTTL `mapstructure:"ttl"`
	MaxSize       int      `mapstructure:"max_size"`
	CleanupOnExit bool     `mapstructure:"cleanup_on_exit"`
}

CacheConfig contains cache settings

type CacheTTL

type CacheTTL struct {
	Metadata      time.Duration `mapstructure:"metadata"`
	Images        time.Duration `mapstructure:"images"`
	SearchResults time.Duration `mapstructure:"search_results"`
	StreamURLs    time.Duration `mapstructure:"stream_urls"`
}

CacheTTL contains TTL for different cache types

type ClipboardConfig

type ClipboardConfig struct {
	Command string `mapstructure:"command"`
}

ClipboardConfig contains clipboard settings

type ColoredTextHandler

type ColoredTextHandler struct {
	// contains filtered or unexported fields
}

ColoredTextHandler wraps slog.TextHandler to add colors for console output

func NewColoredTextHandler

func NewColoredTextHandler(w io.Writer, opts *slog.HandlerOptions) *ColoredTextHandler

NewColoredTextHandler creates a new handler that adds colors for console output

func (*ColoredTextHandler) Enabled

func (h *ColoredTextHandler) Enabled(ctx context.Context, level slog.Level) bool

Enabled implements slog.Handler interface

func (*ColoredTextHandler) Handle

func (h *ColoredTextHandler) Handle(ctx context.Context, r slog.Record) error

Handle implements slog.Handler interface

func (*ColoredTextHandler) WithAttrs

func (h *ColoredTextHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs implements slog.Handler interface

func (*ColoredTextHandler) WithGroup

func (h *ColoredTextHandler) WithGroup(name string) slog.Handler

WithGroup implements slog.Handler interface

type Config

type Config struct {
	API        APIConfig        `mapstructure:"api" yaml:"api"`
	Player     PlayerConfig     `mapstructure:"player" yaml:"player"`
	Providers  ProvidersConfig  `mapstructure:"providers" yaml:"providers"`
	Tracker    TrackerConfig    `mapstructure:"tracker" yaml:"tracker"`
	Downloads  DownloadsConfig  `mapstructure:"downloads" yaml:"downloads"`
	UI         UIConfig         `mapstructure:"ui" yaml:"ui"`
	WatchParty WatchPartyConfig `mapstructure:"watchparty" yaml:"watchparty"`
	Cache      CacheConfig      `mapstructure:"cache" yaml:"cache"`
	Database   DatabaseConfig   `mapstructure:"database" yaml:"database"`
	Logging    LoggingConfig    `mapstructure:"logging" yaml:"logging"`
	Network    NetworkConfig    `mapstructure:"network" yaml:"network"`
	Advanced   AdvancedConfig   `mapstructure:"advanced" yaml:"advanced"`
	// contains filtered or unexported fields
}

Config holds all configuration for the application

func Load

func Load(configPath string) (*Config, *viper.Viper, error)

Load loads configuration from file, environment, and defaults

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to the file

type DatabaseConfig

type DatabaseConfig struct {
	Path           string `mapstructure:"path"`
	WALMode        bool   `mapstructure:"wal_mode"`
	MaxConnections int    `mapstructure:"max_connections"`
	AutoVacuum     bool   `mapstructure:"auto_vacuum"`
	BackupOnExit   bool   `mapstructure:"backup_on_exit"`
}

DatabaseConfig contains database settings

type DefaultProviders

type DefaultProviders struct {
	Anime       string `mapstructure:"anime" yaml:"anime"`
	MoviesAndTV string `mapstructure:"movies_and_tv" yaml:"movies_and_tv"` // Combined field for movies and TV
}

DefaultProviders specifies default provider for each media type

type DownloadsConfig

type DownloadsConfig struct {
	Path                  string   `mapstructure:"path"`
	Concurrent            int      `mapstructure:"concurrent"`
	ConcurrentSegments    int      `mapstructure:"concurrent_segments"`
	EmbedSubtitles        bool     `mapstructure:"embed_subtitles"`
	SubtitleLanguages     []string `mapstructure:"subtitle_languages"`
	AutoResume            bool     `mapstructure:"auto_resume"`
	KeepPartial           bool     `mapstructure:"keep_partial"`
	FilenameTemplate      string   `mapstructure:"filename_template"`
	AnimeFilenameTemplate string   `mapstructure:"anime_filename_template"`
	MovieFilenameTemplate string   `mapstructure:"movie_filename_template"`
	MaxSpeed              int64    `mapstructure:"max_speed"`
	MinFreeSpace          int      `mapstructure:"min_free_space"`
}

DownloadsConfig contains download settings

type LoggingConfig

type LoggingConfig struct {
	Level      string `mapstructure:"level"`
	File       string `mapstructure:"file"`
	MaxSize    int    `mapstructure:"max_size"`
	MaxBackups int    `mapstructure:"max_backups"`
	MaxAge     int    `mapstructure:"max_age"`
	Compress   bool   `mapstructure:"compress"`
	Format     string `mapstructure:"format"`
	Color      bool   `mapstructure:"color"`
}

LoggingConfig contains logging settings

type NetworkConfig

type NetworkConfig struct {
	Timeout         time.Duration `mapstructure:"timeout"`
	HTTP2           bool          `mapstructure:"http2"`
	MaxIdleConns    int           `mapstructure:"max_idle_conns"`
	IdleConnTimeout time.Duration `mapstructure:"idle_conn_timeout"`
	UserAgent       string        `mapstructure:"user_agent"`
	Proxy           string        `mapstructure:"proxy"`
	VerifyTLS       bool          `mapstructure:"verify_tls"`
	DNSServers      []string      `mapstructure:"dns_servers"`
}

NetworkConfig contains network settings

type PlayerConfig

type PlayerConfig struct {
	Binary          string        `mapstructure:"binary"`
	MPVArgs         []string      `mapstructure:"mpv_args"`
	Quality         string        `mapstructure:"quality"`
	Resume          bool          `mapstructure:"resume"`
	SubtitleLang    string        `mapstructure:"subtitle_language"`
	AutoSubtitles   bool          `mapstructure:"auto_subtitles"`
	AudioPreference string        `mapstructure:"audio_preference"`
	LoadUserConfig  bool          `mapstructure:"load_user_config"`
	IPCTimeout      time.Duration `mapstructure:"ipc_timeout"`
}

PlayerConfig contains video player settings

type PreviewSize

type PreviewSize struct {
	Width  int `mapstructure:"width"`
	Height int `mapstructure:"height"`
}

PreviewSize contains preview image dimensions

type PriorityProviders

type PriorityProviders struct {
	Anime  []string `mapstructure:"anime"`
	Movies []string `mapstructure:"movies"`
	TV     []string `mapstructure:"tv"`
}

PriorityProviders specifies provider priority order

type ProviderSettings

type ProviderSettings struct {
	Mode       string        `mapstructure:"mode"`       // "local" or "remote" (Default: "local")
	RemoteURL  string        `mapstructure:"remote_url"` // Target API URL if mode is remote
	Enabled    bool          `mapstructure:"enabled"`
	BaseURL    string        `mapstructure:"base_url"`
	APIURL     string        `mapstructure:"api_url"`
	Timeout    time.Duration `mapstructure:"timeout"`
	MaxRetries int           `mapstructure:"max_retries"`
	RateLimit  int           `mapstructure:"rate_limit"`
}

ProviderSettings contains provider-specific settings

type ProvidersConfig

type ProvidersConfig struct {
	Default             DefaultProviders  `mapstructure:"default" yaml:"default"`
	Priority            PriorityProviders `mapstructure:"priority" yaml:"priority"`
	HealthCheckInterval time.Duration     `mapstructure:"health_check_interval" yaml:"health_check_interval"`
	AutoFailover        bool              `mapstructure:"auto_failover" yaml:"auto_failover"`
	AllAnime            ProviderSettings  `mapstructure:"allanime" yaml:"allanime"`
	HiAnime             ProviderSettings  `mapstructure:"hianime" yaml:"hianime"`
	SFlix               ProviderSettings  `mapstructure:"sflix" yaml:"sflix"`
	FlixHQ              ProviderSettings  `mapstructure:"flixhq" yaml:"flixhq"`
	HDRezka             ProviderSettings  `mapstructure:"hdrezka" yaml:"hdrezka"`
	Comix               ProviderSettings  `mapstructure:"comix" yaml:"comix"`
}

ProvidersConfig contains provider settings

type TrackerConfig

type TrackerConfig struct {
	AniList AniListConfig `mapstructure:"anilist"`
}

TrackerConfig contains tracker settings

type UIConfig

type UIConfig struct {
	Theme            string            `mapstructure:"theme"`
	PreviewImages    bool              `mapstructure:"preview_images"`
	PreviewMethod    string            `mapstructure:"preview_method"`
	MangaMethod      string            `mapstructure:"manga_method"`
	PreviewSize      PreviewSize       `mapstructure:"preview_size"`
	ShowProgress     bool              `mapstructure:"show_progress"`
	Compact          bool              `mapstructure:"compact"`
	Keybindings      map[string]string `mapstructure:"keybindings"`
	DateFormat       string            `mapstructure:"date_format"`
	TimeFormat       string            `mapstructure:"time_format"`
	FuzzyFinder      string            `mapstructure:"fuzzy_finder"`
	ShowLoading      bool              `mapstructure:"show_loading"`
	DefaultMediaType string            `mapstructure:"default_media_type"` // movie_tv, anime, or manga
}

UIConfig contains UI settings

type WatchPartyConfig

type WatchPartyConfig struct {
	Enabled         bool   `mapstructure:"enabled"`
	DefaultProxy    string `mapstructure:"default_proxy"`
	AutoOpenBrowser bool   `mapstructure:"auto_open_browser"`
	DefaultOrigin   string `mapstructure:"default_origin"`
}

WatchPartyConfig contains WatchParty settings

Jump to

Keyboard shortcuts

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