Fix traffic computation and optimize open ended requests
This commit is contained in:
@@ -70,6 +70,10 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
|
||||
tokenMap, _ := rd.UnrestrictMap.Get(token)
|
||||
if tokenMap.Has(link) {
|
||||
download, _ := tokenMap.Get(link)
|
||||
if !rd.cfg.ShouldServeFromRclone() {
|
||||
return download, nil
|
||||
}
|
||||
|
||||
// check if the link is in the verified links cache
|
||||
if expiry, ok := rd.verifiedLinks.Get(download.ID); ok && expiry > time.Now().Unix() {
|
||||
return download, nil
|
||||
@@ -98,17 +102,19 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
|
||||
|
||||
tokenMap.Set(link, download)
|
||||
|
||||
err = rd.downloadClient.VerifyLink(download.Download)
|
||||
if utils.IsBytesLimitReached(err) {
|
||||
rd.TokenManager.SetTokenAsExpired(token, "bandwidth limit exceeded")
|
||||
continue
|
||||
} else if utils.IsInvalidDownloadCode(err) {
|
||||
continue
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if rd.cfg.ShouldServeFromRclone() {
|
||||
err = rd.downloadClient.VerifyLink(download.Download)
|
||||
if utils.IsBytesLimitReached(err) {
|
||||
rd.TokenManager.SetTokenAsExpired(token, "bandwidth limit exceeded")
|
||||
continue
|
||||
} else if utils.IsInvalidDownloadCode(err) {
|
||||
continue
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rd.verifiedLinks.Set(download.ID, time.Now().Unix()+DOWNLOAD_LINK_EXPIRY)
|
||||
rd.verifiedLinks.Set(download.ID, time.Now().Unix()+DOWNLOAD_LINK_EXPIRY)
|
||||
}
|
||||
|
||||
return download, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user