replace '// 1000' with '/ 1000' for timestamp conversions
regular division is slightly faster than floor division and a float timestamp value is treated the same as an integer one
This commit is contained in:
@@ -364,9 +364,9 @@ class TwitterExtractor(Extractor):
|
||||
author = tweet["user"]
|
||||
author = self._transform_user(author)
|
||||
|
||||
if tweet_id >= 300000000000000:
|
||||
if tweet_id >= 300_000_000_000_000:
|
||||
date = self.parse_timestamp(
|
||||
((tweet_id >> 22) + 1288834974657) // 1000)
|
||||
((tweet_id >> 22) + 1_288_834_974_657) / 1000)
|
||||
else:
|
||||
try:
|
||||
date = self.parse_datetime(
|
||||
@@ -461,7 +461,7 @@ class TwitterExtractor(Extractor):
|
||||
if tdata["retweet_id"]:
|
||||
tdata["content"] = f"RT @{author['name']}: {tdata['content']}"
|
||||
tdata["date_original"] = self.parse_timestamp(
|
||||
((tdata["retweet_id"] >> 22) + 1288834974657) // 1000)
|
||||
((tdata["retweet_id"] >> 22) + 1_288_834_974_657) / 1000)
|
||||
|
||||
return tdata
|
||||
|
||||
@@ -497,7 +497,7 @@ class TwitterExtractor(Extractor):
|
||||
"id": text.parse_int(cid),
|
||||
"name": com.get("name"),
|
||||
"description": com.get("description"),
|
||||
"date": self.parse_timestamp(com.get("created_at", 0) // 1000),
|
||||
"date": self.parse_timestamp(com.get("created_at", 0) / 1000),
|
||||
"nsfw": com.get("is_nsfw"),
|
||||
"role": com.get("role"),
|
||||
"member_count": com.get("member_count"),
|
||||
@@ -928,7 +928,7 @@ class TwitterBookmarkExtractor(TwitterExtractor):
|
||||
def _transform_tweet(self, tweet):
|
||||
tdata = TwitterExtractor._transform_tweet(self, tweet)
|
||||
tdata["date_bookmarked"] = self.parse_timestamp(
|
||||
(int(tweet["sortIndex"] or 0) >> 20) // 1000)
|
||||
(int(tweet["sortIndex"] or 0) >> 20) / 1000)
|
||||
return tdata
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user