Add bookmark_count and view_count to the X / Twitter extractor

- Parse `view_count` as integer in Twitter extractor
- Style fix
- optimize 'view_count' extraction
This commit is contained in:
rameerez
2024-06-28 04:44:44 +02:00
committed by Mike Fährmann
parent ea81fa985f
commit ee93dfeb8d

View File

@@ -321,8 +321,17 @@ class TwitterExtractor(Extractor):
"quote_count" : tget("quote_count"),
"reply_count" : tget("reply_count"),
"retweet_count" : tget("retweet_count"),
"bookmark_count": tget("bookmark_count"),
}
if "views" in tweet:
try:
tdata["view_count"] = int(tweet["views"]["count"])
except Exception:
tdata["view_count"] = 0
else:
tdata["view_count"] = 0
if "note_tweet" in tweet:
note = tweet["note_tweet"]["note_tweet_results"]["result"]
content = note["text"]