mirror of
https://github.com/zedeus/nitter.git
synced 2025-03-04 01:51:12 +00:00
Fix rate limit handling
This commit is contained in:
parent
7702576369
commit
5be37737eb
1 changed files with 3 additions and 2 deletions
|
@ -5,7 +5,7 @@ import experimental/parser/session
|
||||||
|
|
||||||
# max requests at a time per session to avoid race conditions
|
# max requests at a time per session to avoid race conditions
|
||||||
const
|
const
|
||||||
maxConcurrentReqs = 3
|
maxConcurrentReqs = 2
|
||||||
dayInSeconds = 24 * 60 * 60
|
dayInSeconds = 24 * 60 * 60
|
||||||
apiMaxReqs: Table[Api, int] = {
|
apiMaxReqs: Table[Api, int] = {
|
||||||
Api.search: 50,
|
Api.search: 50,
|
||||||
|
@ -130,8 +130,9 @@ proc isLimited(session: Session; api: Api): bool =
|
||||||
if (epochTime().int - session.limitedAt) > dayInSeconds:
|
if (epochTime().int - session.limitedAt) > dayInSeconds:
|
||||||
session.limited = false
|
session.limited = false
|
||||||
log "resetting limit: ", session.id
|
log "resetting limit: ", session.id
|
||||||
else:
|
|
||||||
return false
|
return false
|
||||||
|
else:
|
||||||
|
return true
|
||||||
|
|
||||||
if api in session.apis:
|
if api in session.apis:
|
||||||
let limit = session.apis[api]
|
let limit = session.apis[api]
|
||||||
|
|
Loading…
Reference in a new issue