зеркало из
https://github.com/viginum-datalab/twscrape.git
synced 2025-10-29 13:06:13 +02:00
Merge pull request #76 from stygmate/main
Get RT and QT when they are in objects of type TweetWithVisibilityResults
Этот коммит содержится в:
Коммит
100859c8fa
@ -189,10 +189,24 @@ class Tweet(JSONTrait):
|
|||||||
def parse(obj: dict, res: dict):
|
def parse(obj: dict, res: dict):
|
||||||
tw_usr = User.parse(res["users"][obj["user_id_str"]])
|
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}")
|
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}")
|
qt_obj = get_or(res, f"tweets.{qt_id}")
|
||||||
|
|
||||||
doc = Tweet(
|
doc = Tweet(
|
||||||
@ -230,12 +244,8 @@ class Tweet(JSONTrait):
|
|||||||
# issue #42 – restore full rt text
|
# issue #42 – restore full rt text
|
||||||
rt = doc.retweetedTweet
|
rt = doc.retweetedTweet
|
||||||
if rt is not None and rt.user is not None and doc.rawContent.endswith("…"):
|
if rt is not None and rt.user is not None and doc.rawContent.endswith("…"):
|
||||||
# prefix = f"RT @{rt.user.username}: "
|
rt_msg = f"RT @{rt.user.username}: {rt.rawContent}"
|
||||||
# if login changed, old login can be cached in rawContent, so use less strict check
|
if doc.rawContent != rt_msg:
|
||||||
prefix = "RT @"
|
|
||||||
|
|
||||||
rt_msg = f"{prefix}{rt.rawContent}"
|
|
||||||
if doc.rawContent != rt_msg and doc.rawContent.startswith(prefix):
|
|
||||||
doc.rawContent = rt_msg
|
doc.rawContent = rt_msg
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|||||||
Загрузка…
x
Ссылка в новой задаче
Block a user