From a1e60203ffad8aadcaffdc2916741121d2a54a18 Mon Sep 17 00:00:00 2001 From: stygmate <> Date: Fri, 15 Sep 2023 12:03:43 +0200 Subject: [PATCH] Get RT and QT when they are in objects of type TweetWithVisibilityResults --- twscrape/models.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/twscrape/models.py b/twscrape/models.py index 31f5852..906bfa2 100644 --- a/twscrape/models.py +++ b/twscrape/models.py @@ -189,10 +189,24 @@ class Tweet(JSONTrait): def parse(obj: dict, res: dict): tw_usr = User.parse(res["users"][obj["user_id_str"]]) - rt_id = _first(obj, ["retweeted_status_id_str", "retweeted_status_result.result.rest_id"]) + rt_id = _first( + obj, + [ + "retweeted_status_id_str", + "retweeted_status_result.result.rest_id", + "retweeted_status_result.result.tweet.rest_id" + ] + ) rt_obj = get_or(res, f"tweets.{rt_id}") - qt_id = _first(obj, ["quoted_status_id_str", "quoted_status_result.result.rest_id"]) + qt_id = _first( + obj, + [ + "quoted_status_id_str", + "quoted_status_result.result.rest_id" + "quoted_status_result.result.tweet.rest_id" + ] + ) qt_obj = get_or(res, f"tweets.{qt_id}") doc = Tweet(