|
@@ -9,7 +9,8 @@ proc getMedia(thread: Chain | Timeline; agent: string) {.async.} =
|
|
|
getCards(thread, agent),
|
|
getCards(thread, agent),
|
|
|
getPolls(thread, agent))
|
|
getPolls(thread, agent))
|
|
|
|
|
|
|
|
-proc finishTimeline*(json: JsonNode; query: Query; after, agent: string): Future[Timeline] {.async.} =
|
|
|
|
|
|
|
+proc finishTimeline*(json: JsonNode; query: Query; after, agent: string;
|
|
|
|
|
+ media=true): Future[Timeline] {.async.} =
|
|
|
result = getResult[Tweet](json, query, after)
|
|
result = getResult[Tweet](json, query, after)
|
|
|
if json == nil: return
|
|
if json == nil: return
|
|
|
|
|
|
|
@@ -19,10 +20,10 @@ proc finishTimeline*(json: JsonNode; query: Query; after, agent: string): Future
|
|
|
let html = parseHtml(json["items_html"].to(string))
|
|
let html = parseHtml(json["items_html"].to(string))
|
|
|
let thread = parseChain(html)
|
|
let thread = parseChain(html)
|
|
|
|
|
|
|
|
- await getMedia(thread, agent)
|
|
|
|
|
|
|
+ if media: await getMedia(thread, agent)
|
|
|
result.content = thread.content
|
|
result.content = thread.content
|
|
|
|
|
|
|
|
-proc getTimeline*(username, after, agent: string): Future[Timeline] {.async.} =
|
|
|
|
|
|
|
+proc getTimeline*(username, after, agent: string; media=true): Future[Timeline] {.async.} =
|
|
|
var params = toSeq({
|
|
var params = toSeq({
|
|
|
"include_available_features": "1",
|
|
"include_available_features": "1",
|
|
|
"include_entities": "1",
|
|
"include_entities": "1",
|
|
@@ -36,9 +37,9 @@ proc getTimeline*(username, after, agent: string): Future[Timeline] {.async.} =
|
|
|
let headers = genHeaders(agent, base / username, xml=true)
|
|
let headers = genHeaders(agent, base / username, xml=true)
|
|
|
let json = await fetchJson(base / (timelineUrl % username) ? params, headers)
|
|
let json = await fetchJson(base / (timelineUrl % username) ? params, headers)
|
|
|
|
|
|
|
|
- result = await finishTimeline(json, Query(), after, agent)
|
|
|
|
|
|
|
+ result = await finishTimeline(json, Query(), after, agent, media)
|
|
|
|
|
|
|
|
-proc getProfileAndTimeline*(username, agent, after: string): Future[(Profile, Timeline)] {.async.} =
|
|
|
|
|
|
|
+proc getProfileAndTimeline*(username, agent, after: string; media=true): Future[(Profile, Timeline)] {.async.} =
|
|
|
var url = base / username
|
|
var url = base / username
|
|
|
if after.len > 0:
|
|
if after.len > 0:
|
|
|
url = url ? {"max_position": after}
|
|
url = url ? {"max_position": after}
|
|
@@ -49,5 +50,5 @@ proc getProfileAndTimeline*(username, agent, after: string): Future[(Profile, Ti
|
|
|
timeline = parseTimeline(html.select("#timeline > .stream-container"), after)
|
|
timeline = parseTimeline(html.select("#timeline > .stream-container"), after)
|
|
|
profile = parseTimelineProfile(html)
|
|
profile = parseTimelineProfile(html)
|
|
|
|
|
|
|
|
- await getMedia(timeline, agent)
|
|
|
|
|
|
|
+ if media: await getMedia(timeline, agent)
|
|
|
result = (profile, timeline)
|
|
result = (profile, timeline)
|