Nevermind.

This commit is contained in:
Zed 2020-06-17 20:46:45 +02:00
parent 51c7af082d
commit 91f42c4c94
3 changed files with 13 additions and 6 deletions

View File

@ -36,8 +36,8 @@ proc getListMembers*(list: List; after=""): Future[Result[Profile]] {.async.} =
proc getProfile*(username: string): Future[Profile] {.async.} = proc getProfile*(username: string): Future[Profile] {.async.} =
let let
ps = genParams({"screen_name": username}) ps = genParams({"screen_name": username})
url = userLookup ? ps url = userShow ? ps
result = parseUserLookup(await fetch(url, oldApi=true), username) result = parseUserShow(await fetch(url, oldApi=true), username)
proc getTimeline*(id: string; after=""; replies=false): Future[Timeline] {.async.} = proc getTimeline*(id: string; after=""; replies=false): Future[Timeline] {.async.} =
let let

View File

@ -13,7 +13,7 @@ const
mediaTimeline* = timelineApi / "media" mediaTimeline* = timelineApi / "media"
listTimeline* = timelineApi / "list.json" listTimeline* = timelineApi / "list.json"
listMembers* = api / "1.1/lists/members.json" listMembers* = api / "1.1/lists/members.json"
userLookup* = api / "1.1/users/lookup.json" userShow* = api / "1.1/users/show.json"
photoRail* = api / "1.1/statuses/media_timeline.json" photoRail* = api / "1.1/statuses/media_timeline.json"
tweet* = timelineApi / "conversation" tweet* = timelineApi / "conversation"
search* = api / "2/search/adaptive.json" search* = api / "2/search/adaptive.json"

View File

@ -24,10 +24,17 @@ proc parseProfile(js: JsonNode; id=""): Profile =
result.expandProfileEntities(js) result.expandProfileEntities(js)
proc parseUserLookup*(js: JsonNode; username: string): Profile = proc parseUserShow*(js: JsonNode; username: string): Profile =
if js.isNull or js.kind == JArray and js.len == 0 or "error" in js: if js.isNull:
return Profile(username: username) return Profile(username: username)
result = parseProfile(js[0])
with error, js{"errors"}:
result = Profile(username: username)
if error.getError == suspended:
result.suspended = true
return
result = parseProfile(js)
proc parseGraphProfile*(js: JsonNode; username: string): Profile = proc parseGraphProfile*(js: JsonNode; username: string): Profile =
if js.isNull: return if js.isNull: return