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:
17
src/api.nim
17
src/api.nim
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user