Improved handling of errors and included manual refreshing

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
2025-05-08 08:11:25 +01:00
parent fa72756aaf
commit d2566e80d3
3 changed files with 59 additions and 17 deletions

View File

@@ -23,7 +23,7 @@ func New(cookie string) *HTTPClient {
Cookie: cookie,
client: &http.Client{},
rl: rate.NewLimiter(rate.Every(1*time.Second), 15),
rl: rate.NewLimiter(rate.Every(1*time.Second), 10),
ctx: context.Background(),
retries: 3,
}
@@ -52,7 +52,7 @@ func (h *HTTPClient) Get(url string) (*http.Response, error) {
if resp.StatusCode == 429 {
fmt.Println("Rate limit exceeded, retrying...")
h.retries--
time.Sleep(30 * time.Second)
time.Sleep(15 * time.Second)
continue
}