Rename variables for easy reference
This commit is contained in:
@@ -84,9 +84,11 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
|
||||
if expiry, ok := rd.verifiedLinks.Get(download.ID); ok && expiry > time.Now().Unix() {
|
||||
return download, nil
|
||||
} else if ok {
|
||||
// if the link is expired, remove it from the verified links cache
|
||||
rd.verifiedLinks.Remove(download.ID)
|
||||
}
|
||||
|
||||
// check if the link is still valid (not in the cache or expired)
|
||||
err := rd.downloadClient.VerifyLink(download.Download)
|
||||
if utils.IsBytesLimitReached(err) {
|
||||
rd.TokenManager.SetTokenAsExpired(token, "bandwidth limit exceeded")
|
||||
@@ -95,6 +97,7 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
|
||||
rd.verifiedLinks.Set(download.ID, time.Now().Unix()+DOWNLOAD_LINK_EXPIRY)
|
||||
return download, nil
|
||||
}
|
||||
// if verification failed, remove the link from the token map
|
||||
tokenMap.Remove(link)
|
||||
}
|
||||
|
||||
@@ -419,8 +422,10 @@ func (rd *RealDebrid) DownloadFile(req *http.Request) (*http.Response, error) {
|
||||
// MonitorExpiredTokens is a permanent job for monitoring expired tokens if they are still expired
|
||||
func (rd *RealDebrid) MonitorExpiredTokens() {
|
||||
sleepPeriod := 1 * time.Minute
|
||||
i := 0
|
||||
rd.workerPool.Submit(func() {
|
||||
for {
|
||||
i++
|
||||
expiredTokens := rd.TokenManager.GetExpiredTokens()
|
||||
for _, token := range expiredTokens {
|
||||
tokenMap, _ := rd.UnrestrictMap.Get(token)
|
||||
@@ -432,7 +437,12 @@ func (rd *RealDebrid) MonitorExpiredTokens() {
|
||||
}
|
||||
err := rd.downloadClient.VerifyLink(download.Download)
|
||||
if err != nil {
|
||||
skipAll = utils.IsBytesLimitReached(err)
|
||||
if utils.IsBytesLimitReached(err) {
|
||||
if i%15 == 0 {
|
||||
rd.log.Debugf("Token %s is still expired", utils.MaskToken(token))
|
||||
}
|
||||
skipAll = true
|
||||
}
|
||||
return
|
||||
}
|
||||
stillExpired = false
|
||||
|
||||
Reference in New Issue
Block a user