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

Improve timeline support, "no more tweets" message

This commit is contained in:
Zed
2019-06-25 07:36:36 +02:00
parent c4d648e952
commit ac8d0e2052
4 changed files with 38 additions and 13 deletions

View File

@@ -150,7 +150,7 @@ proc getProfile*(username: string): Future[Profile] {.async.} =
result = parsePopupProfile(html)
proc getTimeline*(username: string; after=""): Future[Tweets] {.async.} =
proc getTimeline*(username: string; after=""): Future[Timeline] {.async.} =
let headers = newHttpHeaders({
"Accept": "application/json, text/javascript, */*; q=0.01",
"Referer": $(base / username),
@@ -164,10 +164,19 @@ proc getTimeline*(username: string; after=""): Future[Tweets] {.async.} =
if after.len > 0:
url &= "&max_position=" & after
let html = await fetchHtml(base / url, headers, jsonKey="items_html")
let json = await fetchJson(base / url, headers)
let html = parseHtml(json["items_html"].to(string))
result = parseTweets(html)
await getVideos(result)
result = Timeline(
tweets: parseTweets(html),
minId: json["min_position"].to(string),
hasMore: json["has_more_items"].to(bool),
)
if json.hasKey("max_position"):
result.maxId = json["max_position"].to(string)
await getVideos(result.tweets)
proc getTweet*(id: string): Future[Conversation] {.async.} =
let headers = newHttpHeaders({