1
0
mirror of https://github.com/zedeus/nitter.git synced 2025-12-06 03:55:36 -05:00
This commit is contained in:
Zed
2025-11-17 11:01:20 +01:00
parent 886f2d2a45
commit 6b655cddd8
3 changed files with 1 additions and 57 deletions

View File

@@ -7,20 +7,6 @@ import experimental/parser/session
const const
maxConcurrentReqs = 2 maxConcurrentReqs = 2
hourInSeconds = 60 * 60 hourInSeconds = 60 * 60
apiMaxReqs: Table[Api, int] = {
Api.search: 50,
Api.tweetDetail: 500,
Api.userTweets: 500,
Api.userTweetsAndReplies: 500,
Api.userMedia: 500,
Api.userRestId: 500,
Api.userScreenName: 500,
Api.tweetResult: 500,
Api.list: 500,
Api.listTweets: 500,
Api.listMembers: 500,
Api.listBySlug: 500
}.toTable
var var
sessionPool: seq[Session] sessionPool: seq[Session]
@@ -71,8 +57,7 @@ proc getSessionPoolHealth*(): JsonNode =
for api in session.apis.keys: for api in session.apis.keys:
let let
apiStatus = session.apis[api] apiStatus = session.apis[api]
limit = if apiStatus.limit > 0: apiStatus.limit else: apiMaxReqs.getOrDefault(api, 0) reqs = apiStatus.limit - apiStatus.remaining
reqs = limit - apiStatus.remaining
# no requests made with this session and endpoint since the limit reset # no requests made with this session and endpoint since the limit reset
if apiStatus.reset < now: if apiStatus.reset < now:

View File

@@ -72,21 +72,3 @@ proc parseHook*(s: string; i: var int; v: var User) =
var u: RawUser var u: RawUser
parseHook(s, i, u) parseHook(s, i, u)
v = toUser u v = toUser u
proc parseUser*(json: string; username=""): User =
handleErrors:
case error.code
of suspended: return User(username: username, suspended: true)
of userNotFound: return
else: echo "[error - parseUser]: ", error
result = json.fromJson(User)
proc parseUsers*(json: string; after=""): Result[User] =
result = Result[User](beginning: after.len == 0)
# starting with '{' means it's an error
if json[0] == '[':
let raw = json.fromJson(seq[RawUser])
for user in raw:
result.content.add user.toUser

View File

@@ -1,23 +0,0 @@
import std/tables
from ../../types import User
type
Search* = object
globalObjects*: GlobalObjects
timeline*: Timeline
GlobalObjects = object
users*: Table[string, User]
Timeline = object
instructions*: seq[Instructions]
Instructions = object
addEntries*: tuple[entries: seq[Entry]]
Entry = object
entryId*: string
content*: tuple[operation: Operation]
Operation = object
cursor*: tuple[value, cursorType: string]