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