[twitter] cache 'user_by_…' results (#4719)

This commit is contained in:
Mike Fährmann
2023-10-25 16:45:27 +02:00
parent 95a74be2a5
commit 31dbbffc0b
2 changed files with 4 additions and 2 deletions

View File

@@ -10,7 +10,7 @@
from .common import Extractor, Message from .common import Extractor, Message
from .. import text, util, exception from .. import text, util, exception
from ..cache import cache from ..cache import cache, memcache
import itertools import itertools
import json import json
import re import re
@@ -1194,6 +1194,7 @@ class TwitterAPI():
} }
return self._pagination_users(endpoint, variables) return self._pagination_users(endpoint, variables)
@memcache(keyarg=1)
def user_by_rest_id(self, rest_id): def user_by_rest_id(self, rest_id):
endpoint = "/graphql/1YAM811Q8Ry4XyPpJclURQ/UserByRestId" endpoint = "/graphql/1YAM811Q8Ry4XyPpJclURQ/UserByRestId"
features = self.features.copy() features = self.features.copy()
@@ -1207,6 +1208,7 @@ class TwitterAPI():
} }
return self._call(endpoint, params)["data"]["user"]["result"] return self._call(endpoint, params)["data"]["user"]["result"]
@memcache(keyarg=1)
def user_by_screen_name(self, screen_name): def user_by_screen_name(self, screen_name):
endpoint = "/graphql/XA6F1nJELYg65hxOC2Ekmg/UserByScreenName" endpoint = "/graphql/XA6F1nJELYg65hxOC2Ekmg/UserByScreenName"
params = { params = {

View File

@@ -6,4 +6,4 @@
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
__version__ = "1.26.1" __version__ = "1.26.2-dev"