Remove GetRandomPreferredHost usage
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package config
|
||||
|
||||
import "math/rand"
|
||||
import (
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
type ConfigInterface interface {
|
||||
GetConfig() ZurgConfig
|
||||
|
||||
@@ -78,16 +78,8 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
|
||||
t.log.Fatalf("Cannot get downloads: %v", err)
|
||||
}
|
||||
for i := range downloads {
|
||||
if !t.DownloadCache.Has(downloads[i].Link) {
|
||||
if strings.Contains(downloads[i].Download, "download.real-debrid.") {
|
||||
prefHost := t.Config.GetRandomPreferredHost()
|
||||
if prefHost != "" {
|
||||
downloads[i].Download = replaceHostInURL(downloads[i].Download, prefHost)
|
||||
}
|
||||
}
|
||||
t.cacheDownload(&downloads[i])
|
||||
}
|
||||
}
|
||||
offset += len(downloads)
|
||||
page++
|
||||
if offset >= totalDownloads {
|
||||
@@ -129,13 +121,7 @@ func (t *TorrentManager) UnrestrictUntilOk(link string) *realdebrid.Download {
|
||||
t.log.Warnf("Cannot unrestrict link %s: %v", link, err)
|
||||
return nil
|
||||
}
|
||||
if ret != nil && ret.Link != "" {
|
||||
if strings.Contains(ret.Download, "download.real-debrid.") {
|
||||
prefHost := t.Config.GetRandomPreferredHost()
|
||||
if prefHost != "" {
|
||||
ret.Download = replaceHostInURL(ret.Download, prefHost)
|
||||
}
|
||||
}
|
||||
if ret != nil && ret.Link != "" && ret.Filename != "" {
|
||||
t.cacheDownload(ret)
|
||||
}
|
||||
return ret
|
||||
|
||||
@@ -109,7 +109,7 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, ensureIPv6Host
|
||||
}
|
||||
|
||||
var dialer proxy.Dialer = &net.Dialer{
|
||||
Timeout: time.Duration(timeoutSecs) * time.Second,
|
||||
Timeout: time.Duration(timeoutSecs) * time.Second, // timeout to establish connection
|
||||
}
|
||||
if proxyURLString := cfg.GetProxy(); proxyURLString != "" {
|
||||
proxyURL, err := url.Parse(proxyURLString)
|
||||
|
||||
Reference in New Issue
Block a user