[instagram] add 'metadata' option (#3107)
This commit is contained in:
@@ -1831,6 +1831,20 @@ Description
|
|||||||
It is possible to use ``"all"`` instead of listing all values separately.
|
It is possible to use ``"all"`` instead of listing all values separately.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.instagram.metadata
|
||||||
|
----------------------------
|
||||||
|
Type
|
||||||
|
``bool``
|
||||||
|
Default
|
||||||
|
``false``
|
||||||
|
Description
|
||||||
|
Provide extended ``user`` metadata even when referring to a user by ID,
|
||||||
|
e.g. ``instagram.com/id:12345678``.
|
||||||
|
|
||||||
|
Note: This metadata is always available when referring to a user by name,
|
||||||
|
e.g. ``instagram.com/USERNAME``.
|
||||||
|
|
||||||
|
|
||||||
extractor.instagram.order-files
|
extractor.instagram.order-files
|
||||||
-------------------------------
|
-------------------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -814,13 +814,17 @@ class InstagramRestAPI():
|
|||||||
params = {"username": screen_name}
|
params = {"username": screen_name}
|
||||||
return self._call(endpoint, params=params)["data"]["user"]
|
return self._call(endpoint, params=params)["data"]["user"]
|
||||||
|
|
||||||
|
@memcache(keyarg=1)
|
||||||
def user_by_id(self, user_id):
|
def user_by_id(self, user_id):
|
||||||
endpoint = "/v1/users/{}/info/".format(user_id)
|
endpoint = "/v1/users/{}/info/".format(user_id)
|
||||||
return self._call(endpoint)["user"]
|
return self._call(endpoint)["user"]
|
||||||
|
|
||||||
def user_id(self, screen_name, check_private=True):
|
def user_id(self, screen_name, check_private=True):
|
||||||
if screen_name.startswith("id:"):
|
if screen_name.startswith("id:"):
|
||||||
|
if self.extractor.config("metadata"):
|
||||||
|
self.extractor._user = self.user_by_id(screen_name[3:])
|
||||||
return screen_name[3:]
|
return screen_name[3:]
|
||||||
|
|
||||||
user = self.user_by_name(screen_name)
|
user = self.user_by_name(screen_name)
|
||||||
if user is None:
|
if user is None:
|
||||||
raise exception.AuthorizationError(
|
raise exception.AuthorizationError(
|
||||||
|
|||||||
Reference in New Issue
Block a user