1
0
mirror of https://github.com/zedeus/nitter.git synced 2025-12-13 07:42:48 -05:00

Fix crash on protected profiles

This commit is contained in:
Zed
2019-06-25 13:18:44 +02:00
parent 8000a814df
commit a3285e8410
2 changed files with 12 additions and 8 deletions

View File

@@ -49,11 +49,10 @@ proc fetchJson(url: Uri; headers: HttpHeaders): Future[JsonNode] {.async.} =
var resp = ""
try:
resp = await client.getContent($url)
result = parseJson(resp)
except:
return nil
return parseJson(resp)
proc getGuestToken(): Future[string] {.async.} =
if getTime() - tokenUpdated < tokenLifetime:
return token
@@ -166,7 +165,7 @@ proc getTimeline*(username: string; after=""): Future[Timeline] {.async.} =
url &= "&max_position=" & cleanAfter
let json = await fetchJson(base / url, headers)
let html = parseHtml(json["items_html"].to(string))
if json.isNil: return Timeline()
result = Timeline(
hasMore: json["has_more_items"].to(bool),
@@ -177,6 +176,7 @@ proc getTimeline*(username: string; after=""): Future[Timeline] {.async.} =
if json["new_latent_count"].to(int) == 0:
return
let html = parseHtml(json["items_html"].to(string))
result.tweets = parseTweets(html)
await getVideos(result.tweets)