Commit 815c30bb authored by Netzdenunziant's avatar Netzdenunziant

Replace GraphQL endpoint with normal API endpoint

parent 734c6f52
...@@ -208,8 +208,7 @@ class TwitterSession: ...@@ -208,8 +208,7 @@ class TwitterSession:
return await self.get("https://api.twitter.com/1.1/search/typeahead.json?src=search_box&result_type=users&q=" + urllib.parse.quote(query)) return await self.get("https://api.twitter.com/1.1/search/typeahead.json?src=search_box&result_type=users&q=" + urllib.parse.quote(query))
async def profile_raw(self, username): async def profile_raw(self, username):
obj = json.dumps({"screen_name": username, "withHighlightedLabel": True}) return await self.get("https://api.twitter.com/1.1/users/show.json?screen_name=" + urllib.parse.quote(username))
return await self.get(self._user_url + urllib.parse.quote(obj))
async def get_profile_tweets_raw(self, user_id): async def get_profile_tweets_raw(self, user_id):
return await self.get("https://api.twitter.com/2/timeline/profile/" + str(user_id) +".json?include_tweet_replies=1&include_want_retweets=0&include_reply_count=1&count=1000") return await self.get("https://api.twitter.com/2/timeline/profile/" + str(user_id) +".json?include_tweet_replies=1&include_want_retweets=0&include_reply_count=1&count=1000")
...@@ -390,22 +389,22 @@ class TwitterSession: ...@@ -390,22 +389,22 @@ class TwitterSession:
raise UnexpectedApiError raise UnexpectedApiError
try: try:
user_id = str(profile_raw["data"]["user"]["rest_id"]) user_id = str(profile_raw["id"])
except KeyError: except KeyError:
user_id = None user_id = None
try: try:
profile["screen_name"] = profile_raw["data"]["user"]["legacy"]["screen_name"] profile["screen_name"] = profile_raw["screen_name"]
except KeyError: except KeyError:
profile["screen_name"] = username profile["screen_name"] = username
try: try:
profile["restriction"] = profile_raw["data"]["user"]["legacy"]["profile_interstitial_type"] profile["restriction"] = profile_raw["profile_interstitial_type"]
except KeyError: except KeyError:
pass pass
if profile.get("restriction", None) == "": if profile.get("restriction", None) == "":
del profile["restriction"] del profile["restriction"]
try: try:
profile["protected"] = profile_raw["data"]["user"]["legacy"]["protected"] profile["protected"] = profile_raw["protected"]
except KeyError: except KeyError:
pass pass
profile["exists"] = not is_error(profile_raw, 50) profile["exists"] = not is_error(profile_raw, 50)
...@@ -413,7 +412,7 @@ class TwitterSession: ...@@ -413,7 +412,7 @@ class TwitterSession:
if suspended: if suspended:
profile["suspended"] = suspended profile["suspended"] = suspended
try: try:
profile["has_tweets"] = int(profile_raw["data"]["user"]["legacy"]["statuses_count"]) > 0 profile["has_tweets"] = int(profile_raw["statuses_count"]) > 0
except KeyError: except KeyError:
profile["has_tweets"] = False profile["has_tweets"] = False
......
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