[twitter] slightly improve '_transform_user()'

This commit is contained in:
Mike Fährmann
2021-08-23 22:28:09 +02:00
parent c04f7ab139
commit 5919dc5b5a

View File

@@ -208,11 +208,13 @@ class TwitterExtractor(Extractor):
return tdata return tdata
def _transform_user(self, user): def _transform_user(self, user):
uid = user["id_str"] try:
cache = self._user_cache return self._user_cache[user["id_str"]]
except KeyError:
pass
if uid not in cache: uid = user["id_str"]
cache[uid] = { self._user_cache[uid] = udata = {
"id" : text.parse_int(uid), "id" : text.parse_int(uid),
"name" : user["screen_name"], "name" : user["screen_name"],
"nick" : user["name"], "nick" : user["name"],
@@ -231,7 +233,7 @@ class TwitterExtractor(Extractor):
"media_count" : user["media_count"], "media_count" : user["media_count"],
"statuses_count" : user["statuses_count"], "statuses_count" : user["statuses_count"],
} }
return cache[uid] return udata
def _users_result(self, users): def _users_result(self, users):
userfmt = self.config("users") userfmt = self.config("users")