Skip to content

Commit

Permalink
Nevermind.
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Jun 17, 2020
1 parent 51c7af0 commit 91f42c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ proc getListMembers*(list: List; after=""): Future[Result[Profile]] {.async.} =
proc getProfile*(username: string): Future[Profile] {.async.} =
let
ps = genParams({"screen_name": username})
url = userLookup ? ps
result = parseUserLookup(await fetch(url, oldApi=true), username)
url = userShow ? ps
result = parseUserShow(await fetch(url, oldApi=true), username)

proc getTimeline*(id: string; after=""; replies=false): Future[Timeline] {.async.} =
let
Expand Down
2 changes: 1 addition & 1 deletion src/consts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const
mediaTimeline* = timelineApi / "media"
listTimeline* = timelineApi / "list.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"
tweet* = timelineApi / "conversation"
search* = api / "2/search/adaptive.json"
Expand Down
13 changes: 10 additions & 3 deletions src/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ proc parseProfile(js: JsonNode; id=""): Profile =

result.expandProfileEntities(js)

proc parseUserLookup*(js: JsonNode; username: string): Profile =
if js.isNull or js.kind == JArray and js.len == 0 or "error" in js:
proc parseUserShow*(js: JsonNode; username: string): Profile =
if js.isNull:
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 =
if js.isNull: return
Expand Down

0 comments on commit 91f42c4

Please sign in to comment.