|
|
@@ -18,10 +18,24 @@ proc finishTimeline*(json: JsonNode; query: Query; after, agent: string;
|
|
|
if not json.hasKey("items_html"): return
|
|
|
|
|
|
let html = parseHtml(json["items_html"].to(string))
|
|
|
- let thread = parseChain(html)
|
|
|
+ let timeline = parseChain(html)
|
|
|
|
|
|
- if media: await getMedia(thread, agent)
|
|
|
- result.content = thread.content
|
|
|
+ if media: await getMedia(timeline, agent)
|
|
|
+ result.content = timeline.content
|
|
|
+
|
|
|
+proc getProfileAndTimeline*(username, agent, after: string; media=true): Future[(Profile, Timeline)] {.async.} =
|
|
|
+ var url = base / username
|
|
|
+ if after.len > 0:
|
|
|
+ url = url ? {"max_position": after}
|
|
|
+
|
|
|
+ let
|
|
|
+ headers = genHeaders(agent, base / username, auth=true)
|
|
|
+ html = await fetchHtml(url, headers)
|
|
|
+ timeline = parseTimeline(html.select("#timeline > .stream-container"), after)
|
|
|
+ profile = parseTimelineProfile(html)
|
|
|
+
|
|
|
+ if media: await getMedia(timeline, agent)
|
|
|
+ result = (profile, timeline)
|
|
|
|
|
|
proc getTimeline*(username, after, agent: string; media=true): Future[Timeline] {.async.} =
|
|
|
var params = toSeq({
|
|
|
@@ -39,16 +53,19 @@ proc getTimeline*(username, after, agent: string; media=true): Future[Timeline]
|
|
|
|
|
|
result = await finishTimeline(json, Query(), after, agent, media)
|
|
|
|
|
|
-proc getProfileAndTimeline*(username, agent, after: string; media=true): Future[(Profile, Timeline)] {.async.} =
|
|
|
- var url = base / username
|
|
|
+proc getMediaTimeline*(username, after, agent: string; media=true): Future[Timeline] {.async.} =
|
|
|
+ echo "mediaTimeline"
|
|
|
+ var params = toSeq({
|
|
|
+ "include_available_features": "1",
|
|
|
+ "include_entities": "1",
|
|
|
+ "reset_error_state": "false"
|
|
|
+ })
|
|
|
+
|
|
|
if after.len > 0:
|
|
|
- url = url ? {"max_position": after}
|
|
|
+ params.add {"max_position": after}
|
|
|
|
|
|
- let
|
|
|
- headers = genHeaders(agent, base / username, auth=true)
|
|
|
- html = await fetchHtml(url, headers)
|
|
|
- timeline = parseTimeline(html.select("#timeline > .stream-container"), after)
|
|
|
- profile = parseTimelineProfile(html)
|
|
|
+ let headers = genHeaders(agent, base / username, xml=true)
|
|
|
+ let json = await fetchJson(base / (timelineMediaUrl % username) ? params, headers)
|
|
|
|
|
|
- if media: await getMedia(timeline, agent)
|
|
|
- result = (profile, timeline)
|
|
|
+ result = await finishTimeline(json, Query(kind: QueryKind.media), after, agent, media)
|
|
|
+ result.minId = getLastId(result)
|