Commit c92379b7 authored by nanahira's avatar nanahira

tmp bad

parent 0a2b143e
Pipeline #19457 passed with stage
in 26 seconds
...@@ -45,6 +45,7 @@ FeaturesDict = { ...@@ -45,6 +45,7 @@ FeaturesDict = {
"responsive_web_twitter_blue_verified_badge_is_enabled": False, "responsive_web_twitter_blue_verified_badge_is_enabled": False,
"view_counts_public_visibility_enabled": False, "view_counts_public_visibility_enabled": False,
"view_counts_everywhere_api_enabled": False, "view_counts_everywhere_api_enabled": False,
"longform_notetweets_consumption_enabled": False,
} }
FeaturesJson = json.dumps(FeaturesDict) FeaturesJson = json.dumps(FeaturesDict)
...@@ -57,16 +58,18 @@ def getTwitterSession(): ...@@ -57,16 +58,18 @@ def getTwitterSession():
return twitter_b return twitter_b
def doSearch(screen_name, twitter_b): def doSearch(screen_name, twitter_b):
global isHealthy return None
searchurl_v2 = "https://api.twitter.com/2/search/adaptive.json" #global isHealthy
params_v2 = {"q": "from:@{}".format(screen_name), "count": 1, "spelling_corrections": 0, "tweet_search_mode": "live"} #searchurl_v2 = "https://api.twitter.com/2/search/adaptive.json"
search_v2 = twitter_b.get(searchurl_v2, params=params_v2).json() #params_v2 = {"q": "from:@{}".format(screen_name), "count": 1, "spelling_corrections": 0, "tweet_search_mode": "live"}
isHealthy = 'globalObjects' in search_v2 #response = twitter_b.get(searchurl_v2, params=params_v2)
if isHealthy: #search_v2 = response.json()
return search_v2["globalObjects"]["tweets"] #isHealthy = 'globalObjects' in search_v2
else: #if isHealthy:
print("Rate limit occurred, marking as unavailable.") # return search_v2["globalObjects"]["tweets"]
return None #else:
# print("Search error: " + response.text)
# return None
@app.route('/_healthy') @app.route('/_healthy')
def healthy(): def healthy():
...@@ -246,8 +249,7 @@ def searchban(screen_name): ...@@ -246,8 +249,7 @@ def searchban(screen_name):
} }
get_reply_param = param = {"variables": json.dumps(get_reply_vars), "features": FeaturesJson} 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)
try: try:
ghostban = True ghostban = True
ghostTweetId = None ghostTweetId = None
...@@ -372,7 +374,8 @@ def searchban(screen_name): ...@@ -372,7 +374,8 @@ def searchban(screen_name):
returnjson["tests"]["more_replies"] = {} returnjson["tests"]["more_replies"] = {}
except KeyError as e: except KeyError as e:
print("Errored testing {}".format(screen_name)) print("Errored testing {}".format(screen_name))
print(e) print(e)
print("Response: " + replies.text)
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