Commit 937cae76 authored by nanahira's avatar nanahira

the variables/features migration

parent 5093a721
...@@ -13,6 +13,14 @@ TWITTER_AUTH_KEY = 'AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs% ...@@ -13,6 +13,14 @@ TWITTER_AUTH_KEY = 'AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%
ENDPOINT = endpoint() ENDPOINT = endpoint()
FeaturesDict = {
"responsive_web_uc_gql_enabled": False,
"dont_mention_me_view_api_enabled": False,
"interactive_text_enabled": False,
"responsive_web_edit_tweet_api_enabled": False
}
FeaturesJson = json.dumps(FeaturesDict)
@app.route('/{screen_name}') @app.route('/{screen_name}')
def shadowban(screen_name): def shadowban(screen_name):
# DO IT # DO IT
...@@ -172,17 +180,21 @@ def searchban(screen_name): ...@@ -172,17 +180,21 @@ def searchban(screen_name):
print("User ID of {}: {}".format(screen_name, user_id)) print("User ID of {}: {}".format(screen_name, user_id))
get_reply_vars = { "count": 700, "userId": user_id, get_reply_vars = {
"count": 700, "userId": user_id,
"includePromotedContent": False, "withSuperFollowsUserFields": False, "withBirdwatchPivots": False, "includePromotedContent": False, "withSuperFollowsUserFields": False, "withBirdwatchPivots": False,
"withDownvotePerspective": False, "withReactionsMetadata": False, "withDownvotePerspective": False, "withReactionsMetadata": False,
"withReactionsPerspective": False, "withSuperFollowsTweetFields": False, "withVoice": False, "withV2Timeline": False, "__fs_interactive_text": False, "__fs_responsive_web_uc_gql_enabled": False, "__fs_dont_mention_me_view_api_enabled": False} "withReactionsPerspective": False, "withSuperFollowsTweetFields": False, "withVoice": False, "withV2Timeline": False,
get_reply_param = param = {"variables": json.dumps(get_reply_vars)} }
get_reply_param = param = {"variables": json.dumps(get_reply_vars), "features": FeaturesJson}
replies = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["UserTweetsAndReplies"], "UserTweetsAndReplies"), params=get_reply_param) replies = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["UserTweetsAndReplies"], "UserTweetsAndReplies"), params=get_reply_param)
# print(replies.text) # print(replies.text)
try: try:
maindata = replies.json()["data"]["user"]["result"]["timeline"]["timeline"]["instructions"] repliesJson = replies.json()
print(repliesJson)
maindata = repliesJson["data"]["user"]["result"]["timeline"]["timeline"]["instructions"]
for d in maindata: for d in maindata:
if d["type"] == "TimelineAddEntries": if d["type"] == "TimelineAddEntries":
for ent in d["entries"]: for ent in d["entries"]:
...@@ -207,11 +219,8 @@ def searchban(screen_name): ...@@ -207,11 +219,8 @@ def searchban(screen_name):
"withReactionsPerspective":False, "withReactionsPerspective":False,
"withSuperFollowsTweetFields":False, "withSuperFollowsTweetFields":False,
"withVoice":False, "withVoice":False,
"__fs_interactive_text":False,
"__fs_responsive_web_uc_gql_enabled":False,
"__fs_dont_mention_me_view_api_enabled":False
} }
tweetdetails = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars)}) tweetdetails = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars), "features": FeaturesJson})
insts = tweetdetails.json()["data"]["threaded_conversation_with_injections"]["instructions"] insts = tweetdetails.json()["data"]["threaded_conversation_with_injections"]["instructions"]
...@@ -246,7 +255,7 @@ def searchban(screen_name): ...@@ -246,7 +255,7 @@ def searchban(screen_name):
showmore = True showmore = True
cursor_vars = tweet_detail_vars cursor_vars = tweet_detail_vars
cursor_vars["cursor"] = ent["content"]["itemContent"]["value"] cursor_vars["cursor"] = ent["content"]["itemContent"]["value"]
cursor = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(cursor_vars)}) cursor = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(cursor_vars), "features": FeaturesJson})
cursor_insts = cursor.json()["data"]["threaded_conversation_with_injections"]["instructions"] cursor_insts = cursor.json()["data"]["threaded_conversation_with_injections"]["instructions"]
for c_i in cursor_insts: for c_i in cursor_insts:
...@@ -281,7 +290,7 @@ def searchban(screen_name): ...@@ -281,7 +290,7 @@ def searchban(screen_name):
returnjson["tests"][testField]["tweet"] = replyTweet returnjson["tests"][testField]["tweet"] = replyTweet
except KeyError as e: except KeyError as e:
print("Errored testing {}".format(screen_name)) print("Errored testing {}".format(screen_name))
print(Exception.with_traceback(e)) # print(Exception.with_traceback(e))
returnjson["tests"]["ghost"] = {} returnjson["tests"]["ghost"] = {}
returnjson["tests"]["more_replies"] = {} returnjson["tests"]["more_replies"] = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment