Adjust config names to per minute
This commit is contained in:
@@ -81,7 +81,7 @@ func MainApp(configPath string) {
|
||||
}
|
||||
}
|
||||
|
||||
rateLimiter := http.NewRateLimiter(config.GetAPIRateLimitPerSecond())
|
||||
rateLimiter := http.NewRateLimiter(config.GetAPIRateLimitPerMinute())
|
||||
|
||||
apiClient := http.NewHTTPClient(
|
||||
config.GetToken(),
|
||||
@@ -127,7 +127,7 @@ func MainApp(configPath string) {
|
||||
}
|
||||
defer workerPool.Release()
|
||||
|
||||
torrentsRateLimiter := http.NewRateLimiter(config.GetTorrentsRateLimitPerSecond())
|
||||
torrentsRateLimiter := http.NewRateLimiter(config.GetTorrentsRateLimitPerMinute())
|
||||
|
||||
rd := realdebrid.NewRealDebrid(
|
||||
apiClient,
|
||||
|
||||
@@ -10,7 +10,7 @@ type ConfigInterface interface {
|
||||
EnableRepair() bool
|
||||
EnableRetainFolderNameExtension() bool
|
||||
EnableRetainRDTorrentName() bool
|
||||
GetAPIRateLimitPerSecond() int
|
||||
GetAPIRateLimitPerMinute() int
|
||||
GetApiTimeoutSecs() int
|
||||
GetConfig() ZurgConfig
|
||||
GetDirectories() []string
|
||||
@@ -31,7 +31,7 @@ type ConfigInterface interface {
|
||||
GetRepairEveryMins() int
|
||||
GetRetriesUntilFailed() int
|
||||
GetToken() string
|
||||
GetTorrentsRateLimitPerSecond() int
|
||||
GetTorrentsRateLimitPerMinute() int
|
||||
GetUsername() string
|
||||
GetVersion() string
|
||||
MeetsConditions(directory, torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64, mediaInfos []*ffprobe.ProbeData) bool
|
||||
@@ -48,7 +48,7 @@ type ZurgConfig struct {
|
||||
Version string `yaml:"zurg" json:"-"`
|
||||
Token string `yaml:"token" json:"-"`
|
||||
|
||||
APIRateLimitPerSecond int `yaml:"api_rate_limit_per_second" json:"api_rate_limit_per_second"`
|
||||
APIRateLimitPerMinute int `yaml:"api_rate_limit_per_second" json:"api_rate_limit_per_second"`
|
||||
ApiTimeoutSecs int `yaml:"api_timeout_secs" json:"api_timeout_secs"`
|
||||
AutoAnalyzeNewTorrents bool `yaml:"auto_analyze_new_torrents" json:"auto_analyze_new_torrents"`
|
||||
CacheNetworkTestResults bool `yaml:"cache_network_test_results" json:"cache_network_test_results"`
|
||||
@@ -76,7 +76,7 @@ type ZurgConfig struct {
|
||||
RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"`
|
||||
RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"`
|
||||
ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"`
|
||||
TorrentsRateLimitPerSecond int `yaml:"torrents_rate_limit_per_second" json:"torrents_rate_limit_per_second"`
|
||||
TorrentsRateLimitPerMinute int `yaml:"torrents_rate_limit_per_second" json:"torrents_rate_limit_per_second"`
|
||||
Username string `yaml:"username" json:"username"`
|
||||
}
|
||||
|
||||
@@ -243,16 +243,16 @@ func (z *ZurgConfig) ShouldHideBrokenTorrents() bool {
|
||||
return z.HideBrokenTorrents
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetAPIRateLimitPerSecond() int {
|
||||
if z.APIRateLimitPerSecond == 0 {
|
||||
func (z *ZurgConfig) GetAPIRateLimitPerMinute() int {
|
||||
if z.APIRateLimitPerMinute == 0 {
|
||||
return 250
|
||||
}
|
||||
return z.APIRateLimitPerSecond
|
||||
return z.APIRateLimitPerMinute
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetTorrentsRateLimitPerSecond() int {
|
||||
if z.TorrentsRateLimitPerSecond == 0 {
|
||||
return 1
|
||||
func (z *ZurgConfig) GetTorrentsRateLimitPerMinute() int {
|
||||
if z.TorrentsRateLimitPerMinute == 0 {
|
||||
return 60
|
||||
}
|
||||
return z.TorrentsRateLimitPerSecond
|
||||
return z.TorrentsRateLimitPerMinute
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ type RateLimiter struct {
|
||||
ticker *time.Ticker
|
||||
}
|
||||
|
||||
func NewRateLimiter(apiRateLimitPerSecond int) *RateLimiter {
|
||||
func NewRateLimiter(rateLimitPerMinute int) *RateLimiter {
|
||||
return &RateLimiter{
|
||||
ticker: time.NewTicker(time.Second / time.Duration(apiRateLimitPerSecond)),
|
||||
ticker: time.NewTicker(time.Minute / time.Duration(rateLimitPerMinute)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user