Files
zurg/internal/config/types.go
Ben Sarmiento a851282b2a periodic repair
2024-01-27 14:14:11 +01:00

187 lines
4.8 KiB
Go

package config
type ConfigInterface interface {
GetConfig() ZurgConfig
GetVersion() string
GetToken() string
GetNumOfWorkers() int
GetRefreshEverySeconds() int
GetRepairEveryMinutes() int
EnableRepair() bool
GetHost() string
GetPort() string
GetUsername() string
GetPassword() string
GetProxy() string
GetDirectories() []string
MeetsConditions(directory, torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64) bool
GetOnLibraryUpdate() string
GetNetworkBufferSize() int
EnableRetainFolderNameExtension() bool
EnableRetainRDTorrentName() bool
ShouldIgnoreRenames() bool
ShouldServeFromRclone() bool
ShouldVerifyDownloadLink() bool
ShouldForceIPv6() bool
GetRealDebridTimeout() int
GetRetriesUntilFailed() int
EnableDownloadMount() bool
GetRateLimitSleepSeconds() int
ShouldDeleteRarFiles() bool
}
type ZurgConfig struct {
Version string `yaml:"zurg" json:"-"`
Token string `yaml:"token" json:"-"`
Host string `yaml:"host" json:"host"`
Port string `yaml:"port" json:"port"`
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"password"`
Proxy string `yaml:"proxy" json:"proxy"`
NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"`
RefreshEverySeconds int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"`
RepairEveryMins int `yaml:"repair_every_mins" json:"repair_every_mins"`
IgnoreRenames bool `yaml:"ignore_renames" json:"ignore_renames"`
RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"`
RetainFolderNameExtension bool `yaml:"retain_folder_name_extension" json:"retain_folder_name_extension"`
CanRepair bool `yaml:"enable_repair" json:"enable_repair"`
DeleteRarFiles bool `yaml:"auto_delete_rar_torrents" json:"auto_delete_rar_torrents"`
RealDebridTimeout int `yaml:"realdebrid_timeout_secs" json:"realdebrid_timeout_secs"`
DownloadMount bool `yaml:"enable_download_mount" json:"enable_download_mount"`
RateLimitSleepSeconds int `yaml:"rate_limit_sleep_secs" json:"rate_limit_sleep_secs"`
RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"`
NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"`
ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"`
VerifyDownloadLink bool `yaml:"verify_download_link" json:"verify_download_link"`
ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"`
OnLibraryUpdate string `yaml:"on_library_update" json:"on_library_update"`
}
func (z *ZurgConfig) GetConfig() ZurgConfig {
return *z
}
func (z *ZurgConfig) GetToken() string {
return z.Token
}
func (z *ZurgConfig) GetHost() string {
if z.Host == "" {
return "[::]"
}
return z.Host
}
func (z *ZurgConfig) GetPort() string {
if z.Port == "" {
return "9999"
}
return z.Port
}
func (z *ZurgConfig) GetUsername() string {
return z.Username
}
func (z *ZurgConfig) GetPassword() string {
return z.Password
}
func (z *ZurgConfig) GetProxy() string {
return z.Proxy
}
func (z *ZurgConfig) GetNumOfWorkers() int {
if z.NumOfWorkers == 0 {
return 50
}
return z.NumOfWorkers
}
func (z *ZurgConfig) GetRefreshEverySeconds() int {
if z.RefreshEverySeconds == 0 {
return 60
}
return z.RefreshEverySeconds
}
func (z *ZurgConfig) GetRepairEveryMinutes() int {
if z.RepairEveryMins == 0 {
return 10
}
return z.RepairEveryMins
}
func (z *ZurgConfig) EnableRepair() bool {
return z.CanRepair
}
func (z *ZurgConfig) GetOnLibraryUpdate() string {
return z.OnLibraryUpdate
}
func (z *ZurgConfig) GetNetworkBufferSize() int {
if z.NetworkBufferSize == 0 {
return 64 * 1024 // 64kb
}
return z.NetworkBufferSize
}
func (z *ZurgConfig) EnableRetainFolderNameExtension() bool {
return z.RetainFolderNameExtension
}
func (z *ZurgConfig) EnableRetainRDTorrentName() bool {
return z.RetainRDTorrentName
}
func (z *ZurgConfig) ShouldIgnoreRenames() bool {
return !z.IgnoreRenames
}
func (z *ZurgConfig) ShouldServeFromRclone() bool {
return z.ServeFromRclone
}
func (z *ZurgConfig) ShouldVerifyDownloadLink() bool {
return z.VerifyDownloadLink
}
func (z *ZurgConfig) ShouldForceIPv6() bool {
return z.ForceIPv6
}
func (z *ZurgConfig) GetRetriesUntilFailed() int {
if z.RetriesUntilFailed == 0 {
return 5
}
return z.RetriesUntilFailed
}
func (z *ZurgConfig) EnableDownloadMount() bool {
return z.DownloadMount
}
func (z *ZurgConfig) GetRealDebridTimeout() int {
if z.RealDebridTimeout == 0 {
return 10
}
return z.RealDebridTimeout
}
func (z *ZurgConfig) GetRateLimitSleepSeconds() int {
if z.RateLimitSleepSeconds == 0 {
return 4
}
return z.RateLimitSleepSeconds
}
func (z *ZurgConfig) ShouldDeleteRarFiles() bool {
return z.DeleteRarFiles
}