Use media endpoint for profile media tab

This bypasses "search" rate limits. It now includes media beyond
images and videos (eg. YouTube links are "media"), but the old
behaviour can be restored by clicking search, then filtering "Media"
and excluding retweets and replies.
This commit is contained in:
Zed
2019-10-23 08:34:03 +02:00
parent 0e6ac69a3f
commit ffce6e21ab
6 changed files with 55 additions and 28 deletions
+9
View File
@@ -1,6 +1,7 @@
import httpclient, asyncdispatch, htmlparser
import strutils, json, xmltree, uri
import ../types
import consts
proc genHeaders*(headers: openArray[tuple[key: string, val: string]];
@@ -52,3 +53,11 @@ proc fetchJson*(url: Uri; headers: HttpHeaders): Future[JsonNode] {.async.} =
result = parseJson(resp)
except:
return nil
proc getLastId*(tweets: Result[Tweet]): string =
if tweets.content.len == 0: return
let last = tweets.content[^1]
if last.retweet.isNone:
$last.id
else:
$(get(last.retweet).id)