mirror of
https://github.com/zedeus/nitter
synced 2026-09-06 07:09:31 +00:00
Add experimental GraphQL list members parser
This commit is contained in:
parent
ae7091e69d
commit
a54d6aa1eb
6 changed files with 65 additions and 34 deletions
|
|
@ -1,8 +1,27 @@
|
|||
import jsony
|
||||
import ../types/graphql, user
|
||||
from ../../types import User
|
||||
import user, ../types/[graphuser, graphlistmembers]
|
||||
from ../../types import User, Result, Query, QueryKind
|
||||
|
||||
proc parseGraphUser*(json: string): User =
|
||||
let raw = json.fromJson(GraphUser)
|
||||
result = toUser raw.data.user.result.legacy
|
||||
result.id = raw.data.user.result.restId
|
||||
|
||||
proc parseGraphListMembers*(json, cursor: string): Result[User] =
|
||||
result = Result[User](
|
||||
beginning: cursor.len == 0,
|
||||
query: Query(kind: userList)
|
||||
)
|
||||
|
||||
let raw = json.fromJson(GraphListMembers)
|
||||
for instruction in raw.data.list.membersTimeline.timeline.instructions:
|
||||
if instruction.kind == "TimelineAddEntries":
|
||||
for entry in instruction.entries:
|
||||
case entry.content.entryType
|
||||
of TimelineTimelineItem:
|
||||
let userResult = entry.content.itemContent.userResults.result
|
||||
if userResult.restId.len > 0:
|
||||
result.content.add toUser userResult.legacy
|
||||
of TimelineTimelineCursor:
|
||||
if entry.content.cursorType == "Bottom":
|
||||
result.bottom = entry.content.value
|
||||
|
|
|
|||
Loading…
Reference in a new issue