فهرست منبع

Change user endpoint

Zed 6 سال پیش
والد
کامیت
0e58c36bae
3فایلهای تغییر یافته به همراه5 افزوده شده و 5 حذف شده
  1. 1 1
      src/api.nim
  2. 1 1
      src/consts.nim
  3. 3 3
      src/parser.nim

+ 1 - 1
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

+ 1 - 1
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"

+ 3 - 3
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