Fix logging of premium status
This commit is contained in:
@@ -7,7 +7,10 @@ import (
|
||||
"github.com/debridmediamanager/zurg/pkg/realdebrid"
|
||||
)
|
||||
|
||||
const PREMIUM_THRESHOLD = 172800
|
||||
const (
|
||||
PREMIUM_THRESHOLD = 172800 // 2 days
|
||||
MINIMUM_SLEEP = 60 // 60 seconds
|
||||
)
|
||||
|
||||
func MonitorPremiumStatus(rd *realdebrid.RealDebrid, zurglog *logutil.Logger) {
|
||||
go func() {
|
||||
@@ -18,7 +21,7 @@ func MonitorPremiumStatus(rd *realdebrid.RealDebrid, zurglog *logutil.Logger) {
|
||||
time.Sleep(5 * time.Minute)
|
||||
continue
|
||||
}
|
||||
if userInfo.Premium <= 0 {
|
||||
if userInfo.Premium <= MINIMUM_SLEEP {
|
||||
zurglog.Fatal("Your account is no longer premium, exiting...")
|
||||
} else {
|
||||
if userInfo.Premium <= PREMIUM_THRESHOLD {
|
||||
@@ -28,6 +31,13 @@ func MonitorPremiumStatus(rd *realdebrid.RealDebrid, zurglog *logutil.Logger) {
|
||||
}
|
||||
}
|
||||
remaining := userInfo.Premium - PREMIUM_THRESHOLD
|
||||
if remaining < MINIMUM_SLEEP {
|
||||
// Ensure minimum sleep duration is 60 seconds
|
||||
remaining = MINIMUM_SLEEP
|
||||
} else {
|
||||
// Round up to the nearest multiple of 60 seconds
|
||||
remaining = ((remaining + MINIMUM_SLEEP - 1) / MINIMUM_SLEEP) * MINIMUM_SLEEP
|
||||
}
|
||||
sleepDuration := time.Duration(remaining) * time.Second
|
||||
time.Sleep(sleepDuration)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user