Use GraphQL for profile media tab

This commit is contained in:
Zed 2023-03-22 03:01:34 +01:00
parent 061694a571
commit a5826a3c3d
3 changed files with 12 additions and 5 deletions

View file

@ -30,6 +30,15 @@ proc getGraphUserTweets*(id: string; after=""; replies=false): Future[Timeline]
js = await fetch(url ? params, apiId)
result = parseGraphTimeline(js, after)
proc getGraphUserMedia*(id: string; after=""): Future[Timeline] {.async.} =
if id.len == 0: return
let
cursor = if after.len > 0: "\"cursor\":\"$1\"," % after else: ""
variables = userTweetsVariables % [id, cursor]
params = {"variables": variables, "features": tweetFeatures}
js = await fetch(graphUserMedia ? params, Api.userMedia)
result = parseGraphTimeline(js, after)
proc getGraphListBySlug*(name, list: string): Future[List] {.async.} =
let
variables = %*{"screenName": name, "listSlug": list, "withHighlightedLabel": false}

View file

@ -10,14 +10,12 @@ const
photoRail* = api / "1.1/statuses/media_timeline.json"
status* = api / "1.1/statuses/show"
search* = api / "2/search/adaptive.json"
timelineApi = api / "2/timeline"
mediaTimeline* = timelineApi / "media"
listTimeline* = timelineApi / "list.json"
listTimeline* = api / "2/timeline/list.json"
graphql = api / "graphql"
graphUserTweets* = graphql / "9rys0A7w1EyqVd2ME0QCJg/UserTweets"
graphUserTweetsAndReplies* = graphql / "ehMCHF3Mkgjsfz_aImqOsg/UserTweetsAndReplies"
graphUserMedia* = graphql / "MA_EP2a21zpzNWKRkaPBMg/UserMedia"
graphTweet* = graphql / "6I7Hm635Q6ftv69L8VrSeQ/TweetDetail"
graphUser* = graphql / "8mPfHBetXOg-EHAyeVxUoA/UserByScreenName"
graphUserById* = graphql / "nI8WydSd-X-lQIVo6bdktQ/UserByRestId"

View file

@ -49,7 +49,7 @@ proc fetchProfile*(after: string; query: Query; skipRail=false;
case query.kind
of posts: getGraphUserTweets(userId, after)
of replies: getGraphUserTweets(userId, after, replies=true)
of media: getMediaTimeline(userId, after)
of media: getGraphUserMedia(userId, after)
else: getSearch[Tweet](query, after)
rail =