diff --git a/src/api.nim b/src/api.nim index b3e05e1..a5fee3f 100644 --- a/src/api.nim +++ b/src/api.nim @@ -7,7 +7,7 @@ import experimental/parser as newParser proc getGraphUser*(username: string): Future[User] {.async.} = if username.len == 0: return let - variables = """{"screen_name": "$1"}""" % username + variables = """{"screen_name":"$1"}""" % username params = {"variables": variables, "features": gqlFeatures} js = await fetchRaw(graphUser ? params, Api.userScreenName) result = parseGraphUser(js) @@ -15,7 +15,7 @@ proc getGraphUser*(username: string): Future[User] {.async.} = proc getGraphUserById*(id: string): Future[User] {.async.} = if id.len == 0 or id.any(c => not c.isDigit): return let - variables = """{"rest_id": "$1"}""" % id + variables = """{"userId":"$1"}""" % id params = {"variables": variables, "features": gqlFeatures} js = await fetchRaw(graphUserById ? params, Api.userRestId) result = parseGraphUser(js) @@ -51,7 +51,7 @@ proc getGraphListBySlug*(name, list: string): Future[List] {.async.} = proc getGraphList*(id: string): Future[List] {.async.} = let - variables = """{"listId": "$1"}""" % id + variables = """{"listId":"$1"}""" % id params = {"variables": variables, "features": gqlFeatures} result = parseGraphList(await fetch(graphListById ? params, Api.list)) @@ -90,7 +90,7 @@ proc getFavorites*(id: string; cfg: Config; after=""): Future[Profile] {.async.} proc getGraphTweetResult*(id: string): Future[Tweet] {.async.} = if id.len == 0: return let - variables = """{"rest_id": "$1"}""" % id + variables = """{"rest_id":"$1"}""" % id params = {"variables": variables, "features": gqlFeatures} js = await fetch(graphTweetResult ? params, Api.tweetResult) result = parseGraphTweetResult(js) diff --git a/src/consts.nim b/src/consts.nim index 68ade47..af97c70 100644 --- a/src/consts.nim +++ b/src/consts.nim @@ -15,8 +15,8 @@ const timelineApi = api / "2/timeline" graphql = api / "graphql" - graphUser* = graphql / "u7wQyGi6oExe8_TRWGMq4Q/UserResultByScreenNameQuery" - graphUserById* = graphql / "oPppcargziU1uDQHAUmH-A/UserResultByIdQuery" + graphUser* = graphql / "32pL5BWe9WKeSK1MoPvFQQ/UserByScreenName" + graphUserById* = graphql / "5vdJ5sWkbSRDiiNZvwc2Yg/UserByRestId" graphUserTweets* = graphql / "3JNH4e9dq1BifLxAa3UMWg/UserWithProfileTweetsQueryV2" graphUserTweetsAndReplies* = graphql / "8IS8MaO-2EN6GZZZb8jF0g/UserWithProfileTweetsAndRepliesQueryV2" graphUserMedia* = graphql / "dexO_2tohK86JDudXXG3Yw/UserMedia" @@ -104,7 +104,10 @@ const "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 + "rweb_video_screen_enabled": false, + "responsive_web_twitter_article_notes_tab_enabled": false, + "subscriptions_feature_can_gift_premium": false, + "hidden_profile_subscriptions_enabled": true }""".replace(" ", "").replace("\n", "") tweetVariables* = """{ diff --git a/src/parser.nim b/src/parser.nim index 13dcfee..920cae7 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -33,7 +33,11 @@ proc parseGraphUser(js: JsonNode): User = var user = js{"user_result", "result"} if user.isNull: user = ? js{"user_results", "result"} - + if user.isNull: + user = js{"data", "user", "result"} + if user.isNull: + user = ? js{"data", "user", "result"} + result = parseUser(user{"legacy"}) if result.verifiedType == VerifiedType.none and user{"is_blue_verified"}.getBool(false): diff --git a/src/routes/activityspoof.nim b/src/routes/activityspoof.nim index 2e976ea..c779546 100644 --- a/src/routes/activityspoof.nim +++ b/src/routes/activityspoof.nim @@ -19,7 +19,10 @@ proc createActivityPubRouter*(cfg: Config) = if id.len == 0: resp Http200, {"Content-Type": "application/json"}, """[]""" - let username = await getCachedUsername(id) + var username = await getCachedUsername(id) + if username.len > 0: + let tmpuser = await getGraphUserById(id) + username = tmpuser.username if username.len > 0: resp Http404, {"Content-Type": "application/json"}, """{"error":"Invalid account ID"}"""