Commit 9e65bf45 authored by nanahira's avatar nanahira

update search suggestion ban thing

parent c2a36243
Pipeline #27423 passed with stages
in 48 seconds
......@@ -91,7 +91,7 @@ def getTwitterSession(specifyCookie = None):
def doSearch(screen_name):
global isHealthy
twitter_b = getTwitterSession()
searchurl_v2 = "https://twitter.com/i/api/graphql/nK1dw4oV3k4w5TdtcAdSww/SearchTimeline"
searchurl_v2 = "https://x.com/i/api/graphql/nK1dw4oV3k4w5TdtcAdSww/SearchTimeline"
params_v2 = {
"features": json.dumps({
"rweb_lists_timeline_redesign_enabled": True,
......@@ -162,7 +162,7 @@ def checkCookies():
if response.status_code == 200:
return True
usertlurl = 'https://twitter.com/i/api/graphql/oUZZZ8Oddwxs8Cd3iW3UEA/UserByScreenName'
usertlurl = 'https://x.com/i/api/graphql/oUZZZ8Oddwxs8Cd3iW3UEA/UserByScreenName'
screen_name = 'Sena_n_Karin'
params = {
'variables': json.dumps({
......@@ -275,7 +275,7 @@ def searchban(screen_name):
# check whether the user has any tweets
#usertlurl = "https://api.twitter.com/1.1/statuses/user_timeline.json"
#params = {"screen_name": screen_name, "count": 200}
usertlurl = 'https://twitter.com/i/api/graphql/oUZZZ8Oddwxs8Cd3iW3UEA/UserByScreenName'
usertlurl = 'https://x.com/i/api/graphql/oUZZZ8Oddwxs8Cd3iW3UEA/UserByScreenName'
params = {
'variables': json.dumps({
'screen_name': screen_name,
......@@ -358,11 +358,14 @@ def searchban(screen_name):
# return returnjson
print("Checking search suggestion banned of {}".format(screen_name))
suggestions = twitter_b.get("https://api.twitter.com/1.1/search/typeahead.json?src=search_box&result_type=users&q=@" + screen_name).json()
suggestions = twitter_b.get("https://x.com/i/api/1.1/search/typeahead.json?include_ext_is_blue_verified=1&include_ext_verified_type=1&include_ext_profile_image_shape=1&src=search_box&result_type=users&q=@" + screen_name).json()
print("Suggestions: " + str(suggestions))
try:
returnjson["tests"]["typeahead"] = len([1 for user in suggestions["users"] if user["screen_name"].lower() == screen_name.lower()]) > 0
except:
returnjson["tests"]["typeahead"] = False
hasFailure = True
print("Error checking typeahead of {}".format(screen_name))
returnjson["tests"]["typeahead"] = '_error'
if returnjson["tests"]["typeahead"] == False:
print("{} is search suggestion banned, checking search ban.".format(screen_name))
......@@ -422,7 +425,7 @@ def searchban(screen_name):
replies = None
try:
replies = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["UserTweetsAndReplies"], "UserTweetsAndReplies"), params=get_reply_param)
replies = twitter_b.get("https://x.com/i/api/graphql/{}/{}".format(ENDPOINT["UserTweetsAndReplies"], "UserTweetsAndReplies"), params=get_reply_param)
ghostban = True
ghostTweetId = None
ghostReplyId = None
......@@ -464,7 +467,7 @@ def searchban(screen_name):
"withSuperFollowsTweetFields":False,
"withVoice":False,
}
tweetdetails = twitter_b.get("https://twitter.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars), "features": FeaturesJson})
tweetdetails = twitter_b.get("https://x.com/i/api/graphql/{}/{}".format(ENDPOINT["TweetDetail"], "TweetDetail"), params={"variables": json.dumps(tweet_detail_vars), "features": FeaturesJson})
tweetData = tweetdetails.json()["data"]
if "threaded_conversation_with_injections" not in tweetData:
continue
......@@ -491,7 +494,7 @@ def searchban(screen_name):
# showmore = True
cursor_vars = tweet_detail_vars
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), "features": FeaturesJson})
cursor = twitter_b.get("https://x.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"]
for c_i in cursor_insts:
......
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