Refactor unrestricting
This commit is contained in:
@@ -196,7 +196,7 @@ func (z *ZurgConfig) GetDownloadTimeoutSecs() int {
|
||||
|
||||
func (z *ZurgConfig) GetRateLimitSleepSecs() int {
|
||||
if z.RateLimitSleepSecs == 0 {
|
||||
return 6
|
||||
return 4
|
||||
}
|
||||
return z.RateLimitSleepSecs
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ func (r *HTTPClient) shouldRetry(resp *http.Response, reqHasRangeHeader bool, er
|
||||
switch apiErr.Code {
|
||||
case -1: // Internal error
|
||||
return 1
|
||||
case 5: // Slow down (retry infinitely)
|
||||
case 5: // Slow down (retry infinitely), default: 4 secs
|
||||
time.Sleep(time.Duration(rateLimitSleep) * time.Second)
|
||||
return 0
|
||||
case 6: // Ressource unreachable
|
||||
@@ -272,7 +272,7 @@ func (r *HTTPClient) shouldRetry(resp *http.Response, reqHasRangeHeader bool, er
|
||||
return 1
|
||||
case 25: // Service unavailable
|
||||
return 1
|
||||
case 34: // Too many requests (retry infinitely)
|
||||
case 34: // Too many requests (retry infinitely), default: 4 secs
|
||||
time.Sleep(time.Duration(rateLimitSleep) * time.Second)
|
||||
return 0
|
||||
case 36: // Fair Usage Limit
|
||||
@@ -287,7 +287,7 @@ func (r *HTTPClient) shouldRetry(resp *http.Response, reqHasRangeHeader bool, er
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode == 429 {
|
||||
// Too many requests: retry infinitely
|
||||
// Too many requests: retry infinitely, default: 4 secs
|
||||
time.Sleep(time.Duration(rateLimitSleep) * time.Second)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -69,6 +69,10 @@ func (rd *RealDebrid) UnrestrictCheck(link string) (*Download, error) {
|
||||
|
||||
func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*Download, error) {
|
||||
data := url.Values{}
|
||||
if strings.HasPrefix(link, "https://real-debrid.com/d/") {
|
||||
// set link to max 39 chars
|
||||
link = link[0:39]
|
||||
}
|
||||
data.Set("link", link)
|
||||
requestBody := strings.NewReader(data.Encode())
|
||||
|
||||
@@ -106,6 +110,7 @@ func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*Downloa
|
||||
return nil, fmt.Errorf("undecodable response: %v", err)
|
||||
}
|
||||
|
||||
// will only check for first byte if serving from rclone
|
||||
if checkFirstByte && !rd.downloadClient.CanFetchFirstByte(response.Download) {
|
||||
return nil, fmt.Errorf("can't fetch first byte")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user