Initial translation implementation #273
This commit is contained in:
@@ -77,6 +77,7 @@ def getApiResponse(tweet,include_txt=False,include_rtf=False):
|
||||
oldTweetVersion = False
|
||||
tweetArticle=None
|
||||
lang=None
|
||||
translation=None
|
||||
|
||||
if "screen_name" not in userL:
|
||||
userL["screen_name"] = user["core"]["screen_name"]
|
||||
@@ -85,6 +86,14 @@ def getApiResponse(tweet,include_txt=False,include_rtf=False):
|
||||
if "profile_image_url_https" not in userL:
|
||||
userL["profile_image_url_https"] = user["avatar"]["image_url"]
|
||||
|
||||
if "grok_translated_post_with_availability" in tweet and tweet["grok_translated_post_with_availability"]["is_available"] and "data" in tweet["grok_translated_post_with_availability"]:
|
||||
tlData = tweet["grok_translated_post_with_availability"]["data"]
|
||||
translation = {
|
||||
"source_language":tlData["source_language"],
|
||||
"destination_language":tlData["destination_language"],
|
||||
"text":tlData["translation"]
|
||||
}
|
||||
|
||||
#editedTweet=False
|
||||
try:
|
||||
if "birdwatch_pivot" in tweet:
|
||||
@@ -305,6 +314,7 @@ def getApiResponse(tweet,include_txt=False,include_rtf=False):
|
||||
"replyingToID": replyingToID,
|
||||
"fetched_on": int(datetime.now().timestamp()),
|
||||
"retweetURL":retweetURL,
|
||||
"translation":translation
|
||||
}
|
||||
try:
|
||||
apiObject["date_epoch"] = int(datetime.strptime(tweetL["created_at"], "%a %b %d %H:%M:%S %z %Y").timestamp())
|
||||
|
||||
Reference in New Issue
Block a user