[instagram] fix GraphQL bugs
This commit is contained in:
@@ -868,14 +868,15 @@ class InstagramGraphqlAPI():
|
|||||||
url, params=params, headers=headers, cookies=cookies,
|
url, params=params, headers=headers, cookies=cookies,
|
||||||
).json()["data"]
|
).json()["data"]
|
||||||
|
|
||||||
def _pagination(self, query_hash, variables, key="user", edge=None):
|
def _pagination(self, query_hash, variables,
|
||||||
|
key_data="user", key_edge=None):
|
||||||
cursor = self.extractor.config("cursor")
|
cursor = self.extractor.config("cursor")
|
||||||
if cursor:
|
if cursor:
|
||||||
variables["after"] = cursor
|
variables["after"] = cursor
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
data = self._call(query_hash, variables)[key]
|
data = self._call(query_hash, variables)[key_data]
|
||||||
data = data[edge] if edge else next(iter(data.values()))
|
data = data[key_edge] if key_edge else next(iter(data.values()))
|
||||||
|
|
||||||
for edge in data["edges"]:
|
for edge in data["edges"]:
|
||||||
yield edge["node"]
|
yield edge["node"]
|
||||||
@@ -889,7 +890,7 @@ class InstagramGraphqlAPI():
|
|||||||
"%s'%s posts are private", self.item, s)
|
"%s'%s posts are private", self.item, s)
|
||||||
|
|
||||||
variables["after"] = self._cursor = info["end_cursor"]
|
variables["after"] = self._cursor = info["end_cursor"]
|
||||||
self.log.debug("Cursor: %s", self._cursor)
|
self.extractor.log.debug("Cursor: %s", self._cursor)
|
||||||
|
|
||||||
|
|
||||||
@cache(maxage=360*24*3600, keyarg=1)
|
@cache(maxage=360*24*3600, keyarg=1)
|
||||||
|
|||||||
Reference in New Issue
Block a user