[instagram] add 'metadata' option (#3107)

This commit is contained in:
Mike Fährmann
2023-05-27 15:51:13 +02:00
parent 8cf13f8696
commit 28f6487c64
2 changed files with 18 additions and 0 deletions

View File

@@ -814,13 +814,17 @@ class InstagramRestAPI():
params = {"username": screen_name}
return self._call(endpoint, params=params)["data"]["user"]
@memcache(keyarg=1)
def user_by_id(self, user_id):
endpoint = "/v1/users/{}/info/".format(user_id)
return self._call(endpoint)["user"]
def user_id(self, screen_name, check_private=True):
if screen_name.startswith("id:"):
if self.extractor.config("metadata"):
self.extractor._user = self.user_by_id(screen_name[3:])
return screen_name[3:]
user = self.user_by_name(screen_name)
if user is None:
raise exception.AuthorizationError(