Fix tweets not loading
This commit is contained in:
parent
6e86e086c3
commit
c7d6b4291c
4 changed files with 59 additions and 50 deletions
|
@ -100,7 +100,7 @@ proc getGraphTweet(id: string; after=""): Future[Conversation] {.async.} =
|
||||||
let
|
let
|
||||||
cursor = if after.len > 0: "\"cursor\":\"$1\"," % after else: ""
|
cursor = if after.len > 0: "\"cursor\":\"$1\"," % after else: ""
|
||||||
variables = tweetVariables % [id, cursor]
|
variables = tweetVariables % [id, cursor]
|
||||||
params = {"variables": variables, "features": gqlFeatures}
|
params = {"variables": variables, "features": gqlFeatures, "fieldToggles": tweetFieldToggles}
|
||||||
js = await fetch(graphTweet ? params, Api.tweetDetail)
|
js = await fetch(graphTweet ? params, Api.tweetDetail)
|
||||||
result = parseGraphConversation(js, id)
|
result = parseGraphConversation(js, id)
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,8 @@ template fetchImpl(result, additional_headers, fetchBody) {.dirty.} =
|
||||||
#release(token, used=true)
|
#release(token, used=true)
|
||||||
|
|
||||||
if resp.status == $Http400:
|
if resp.status == $Http400:
|
||||||
raise newException(InternalError, $url)
|
let errText = "body: '" & result & "' url: " & $url
|
||||||
|
raise newException(InternalError, errText)
|
||||||
except InternalError as e:
|
except InternalError as e:
|
||||||
raise e
|
raise e
|
||||||
except BadClientError as e:
|
except BadClientError as e:
|
||||||
|
|
|
@ -20,7 +20,7 @@ const
|
||||||
graphUserTweets* = graphql / "3JNH4e9dq1BifLxAa3UMWg/UserWithProfileTweetsQueryV2"
|
graphUserTweets* = graphql / "3JNH4e9dq1BifLxAa3UMWg/UserWithProfileTweetsQueryV2"
|
||||||
graphUserTweetsAndReplies* = graphql / "8IS8MaO-2EN6GZZZb8jF0g/UserWithProfileTweetsAndRepliesQueryV2"
|
graphUserTweetsAndReplies* = graphql / "8IS8MaO-2EN6GZZZb8jF0g/UserWithProfileTweetsAndRepliesQueryV2"
|
||||||
graphUserMedia* = graphql / "dexO_2tohK86JDudXXG3Yw/UserMedia"
|
graphUserMedia* = graphql / "dexO_2tohK86JDudXXG3Yw/UserMedia"
|
||||||
graphTweet* = graphql / "q94uRCEn65LZThakYcPT6g/TweetDetail"
|
graphTweet* = graphql / "y90SwUGBZ3yz0yNUmCHgTw/TweetDetail"
|
||||||
graphTweetResult* = graphql / "sITyJdhRPpvpEjg4waUmTA/TweetResultByIdQuery"
|
graphTweetResult* = graphql / "sITyJdhRPpvpEjg4waUmTA/TweetResultByIdQuery"
|
||||||
graphSearchTimeline* = graphql / "gkjsKepM6gl_HmFWoWKfgg/SearchTimeline"
|
graphSearchTimeline* = graphql / "gkjsKepM6gl_HmFWoWKfgg/SearchTimeline"
|
||||||
graphListById* = graphql / "iTpgCtbdxrsJfyx0cFjHqg/ListByRestId"
|
graphListById* = graphql / "iTpgCtbdxrsJfyx0cFjHqg/ListByRestId"
|
||||||
|
@ -95,30 +95,36 @@ const
|
||||||
"unified_cards_ad_metadata_container_dynamic_card_content_query_enabled": false,
|
"unified_cards_ad_metadata_container_dynamic_card_content_query_enabled": false,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
"vibe_api_enabled": false,
|
"vibe_api_enabled": false,
|
||||||
"view_counts_everywhere_api_enabled": false
|
"view_counts_everywhere_api_enabled": false,
|
||||||
|
"premium_content_api_read_enabled": false,
|
||||||
|
"responsive_web_grok_analyze_button_fetch_trends_enabled": false,
|
||||||
|
"responsive_web_grok_analysis_button_from_backend": false,
|
||||||
|
"responsive_web_grok_analyze_post_followups_enabled": false,
|
||||||
|
"responsive_web_jetfuel_frame": false,
|
||||||
|
"profile_label_improvements_pcf_label_in_post_enabled": true,
|
||||||
|
"responsive_web_grok_image_annotation_enabled": false,
|
||||||
|
"responsive_web_grok_share_attachment_enabled": false,
|
||||||
|
"rweb_video_screen_enabled": false
|
||||||
}""".replace(" ", "").replace("\n", "")
|
}""".replace(" ", "").replace("\n", "")
|
||||||
|
|
||||||
tweetVariables* = """{
|
tweetVariables* = """{
|
||||||
"focalTweetId": "$1",
|
"focalTweetId": "$1",
|
||||||
$2
|
$2
|
||||||
"includeHasBirdwatchNotes": false,
|
"with_rux_injections": false,
|
||||||
|
"rankingMode": "Relevance",
|
||||||
"includePromotedContent": false,
|
"includePromotedContent": false,
|
||||||
"withBirdwatchNotes": false,
|
"withCommunity": true,
|
||||||
"withVoice": false,
|
"withQuickPromoteEligibilityTweetFields": false,
|
||||||
"withV2Timeline": true
|
"withBirdwatchNotes": true,
|
||||||
|
"withVoice": true
|
||||||
}""".replace(" ", "").replace("\n", "")
|
}""".replace(" ", "").replace("\n", "")
|
||||||
|
|
||||||
# oldUserTweetsVariables* = """{
|
tweetFieldToggles* = """{
|
||||||
# "userId": "$1", $2
|
"withArticleRichContentState": false,
|
||||||
# "count": 20,
|
"withArticlePlainText": true,
|
||||||
# "includePromotedContent": false,
|
"withGrokAnalyze": false,
|
||||||
# "withDownvotePerspective": false,
|
"withDisallowedReplyControls": false
|
||||||
# "withReactionsMetadata": false,
|
}""".replace(" ", "").replace("\n", "")
|
||||||
# "withReactionsPerspective": false,
|
|
||||||
# "withVoice": false,
|
|
||||||
# "withV2Timeline": true
|
|
||||||
# }
|
|
||||||
# """.replace(" ", "").replace("\n", "")
|
|
||||||
|
|
||||||
userTweetsVariables* = """{
|
userTweetsVariables* = """{
|
||||||
"rest_id": "$1",
|
"rest_id": "$1",
|
||||||
|
|
|
@ -505,39 +505,41 @@ proc parseGraphConversation*(js: JsonNode; tweetId: string): Conversation =
|
||||||
if instructions.len == 0:
|
if instructions.len == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
for e in instructions[0]{"entries"}:
|
for i in instructions:
|
||||||
let entryId = e{"entryId"}.getStr
|
if i{"type"}.getStr == "TimelineAddEntries":
|
||||||
if entryId.startsWith("tweet"):
|
for e in i{"entries"}:
|
||||||
with tweetResult, e{"content", "itemContent", "tweet_results", "result"}:
|
let entryId = e{"entryId"}.getStr
|
||||||
let tweet = parseGraphTweet(tweetResult, true)
|
if entryId.startsWith("tweet"):
|
||||||
|
with tweetResult, e{"content", "itemContent", "tweet_results", "result"}:
|
||||||
|
let tweet = parseGraphTweet(tweetResult, true)
|
||||||
|
|
||||||
if not tweet.available:
|
if not tweet.available:
|
||||||
tweet.id = parseBiggestInt(entryId.getId())
|
tweet.id = parseBiggestInt(entryId.getId())
|
||||||
|
|
||||||
if $tweet.id == tweetId:
|
if $tweet.id == tweetId:
|
||||||
result.tweet = tweet
|
result.tweet = tweet
|
||||||
else:
|
else:
|
||||||
result.before.content.add tweet
|
result.before.content.add tweet
|
||||||
elif entryId.startsWith("tombstone"):
|
elif entryId.startsWith("tombstone"):
|
||||||
let id = entryId.getId()
|
let id = entryId.getId()
|
||||||
let tweet = Tweet(
|
let tweet = Tweet(
|
||||||
id: parseBiggestInt(id),
|
id: parseBiggestInt(id),
|
||||||
available: false,
|
available: false,
|
||||||
text: e{"content", "itemContent", "tombstoneInfo", "richText"}.getTombstone
|
text: e{"content", "itemContent", "tombstoneInfo", "richText"}.getTombstone
|
||||||
)
|
)
|
||||||
|
|
||||||
if id == tweetId:
|
if id == tweetId:
|
||||||
result.tweet = tweet
|
result.tweet = tweet
|
||||||
else:
|
else:
|
||||||
result.before.content.add tweet
|
result.before.content.add tweet
|
||||||
elif entryId.startsWith("conversationthread") or entryId.startswith("reply-mixer-conversation"):
|
elif entryId.startsWith("conversationthread") or entryId.startswith("reply-mixer-conversation"):
|
||||||
let (thread, self) = parseGraphThread(e)
|
let (thread, self) = parseGraphThread(e)
|
||||||
if self:
|
if self:
|
||||||
result.after = thread
|
result.after = thread
|
||||||
else:
|
else:
|
||||||
result.replies.content.add thread
|
result.replies.content.add thread
|
||||||
elif entryId.startsWith("cursor-bottom"):
|
elif entryId.startsWith("cursor-bottom"):
|
||||||
result.replies.bottom = e{"content", "itemContent", "value"}.getStr
|
result.replies.bottom = e{"content", "value"}.getStr
|
||||||
|
|
||||||
proc parseGraphTimeline*(js: JsonNode; root: string; after=""): Profile =
|
proc parseGraphTimeline*(js: JsonNode; root: string; after=""): Profile =
|
||||||
result = Profile(tweets: Timeline(beginning: after.len == 0))
|
result = Profile(tweets: Timeline(beginning: after.len == 0))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue