From 0e58c36baefb96acc8bcef9bce9de4c2f4b0dd02 Mon Sep 17 00:00:00 2001 From: Zed Date: Wed, 17 Jun 2020 00:22:11 +0200 Subject: [PATCH] Change user endpoint --- src/api.nim | 2 +- src/consts.nim | 2 +- src/parser.nim | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api.nim b/src/api.nim index a18e998..33dc505 100644 --- a/src/api.nim +++ b/src/api.nim @@ -37,7 +37,7 @@ proc getProfile*(username: string): Future[Profile] {.async.} = let ps = genParams({"screen_name": username}) url = userLookup ? ps - result = parseUserShow(await fetch(url, oldApi=true), username) + result = parseUserLookup(await fetch(url, oldApi=true), username) proc getTimeline*(id: string; after=""; replies=false): Future[Timeline] {.async.} = let diff --git a/src/consts.nim b/src/consts.nim index b303190..5e8e386 100644 --- a/src/consts.nim +++ b/src/consts.nim @@ -13,7 +13,7 @@ const mediaTimeline* = timelineApi / "media" listTimeline* = timelineApi / "list.json" listMembers* = api / "1.1/lists/members.json" - userLookup* = api / "1.1/users/show.json" + userLookup* = api / "1.1/users/lookup.json" photoRail* = api / "1.1/statuses/media_timeline.json" tweet* = timelineApi / "conversation" search* = api / "2/search/adaptive.json" diff --git a/src/parser.nim b/src/parser.nim index a4f1649..2354092 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -24,15 +24,15 @@ proc parseProfile(js: JsonNode; id=""): Profile = result.expandProfileEntities(js) -proc parseUserShow*(js: JsonNode; username: string): Profile = - if js.isNull: return +proc parseUserLookup*(js: JsonNode; username: string): Profile = + if js.isNull or js.kind == JArray and js.len == 0: return with error, js{"errors"}: result = Profile(username: username) if error.getError == suspended: result.suspended = true return - result = parseProfile(js) + result = parseProfile(js[0]) proc parseGraphProfile*(js: JsonNode; username: string): Profile = if js.isNull: return