mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Use dynamic rate limits from API responses
This commit is contained in:
parent
6fe850b2c6
commit
4fc7b873c4
3 changed files with 11 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ import experimental/types/common
|
|||
const
|
||||
rlRemaining = "x-rate-limit-remaining"
|
||||
rlReset = "x-rate-limit-reset"
|
||||
rlLimit = "x-rate-limit-limit"
|
||||
errorsToSkip = {doesntExist, tweetNotFound, timeout, unauthorized, badRequest}
|
||||
|
||||
var pool: HttpPool
|
||||
|
|
@ -83,7 +84,8 @@ template fetchImpl(result, fetchBody) {.dirty.} =
|
|||
let
|
||||
remaining = parseInt(resp.headers[rlRemaining])
|
||||
reset = parseInt(resp.headers[rlReset])
|
||||
session.setRateLimit(api, remaining, reset)
|
||||
limit = parseInt(resp.headers[rlLimit])
|
||||
session.setRateLimit(api, remaining, reset, limit)
|
||||
|
||||
if result.len > 0:
|
||||
if resp.headers.getOrDefault("content-encoding") == "gzip":
|
||||
|
|
|
|||
Loading…
Reference in a new issue