Merge branch 'master' into v4-dev
This commit is contained in:
commit
b0a8bfbcf4
@ -1096,7 +1096,7 @@ class Instaloader:
|
|||||||
def test_login(self) -> Optional[str]:
|
def test_login(self) -> Optional[str]:
|
||||||
"""Returns the Instagram username to which given :class:`requests.Session` object belongs, or None."""
|
"""Returns the Instagram username to which given :class:`requests.Session` object belongs, or None."""
|
||||||
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3", {})
|
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3", {})
|
||||||
return data["data"]["user"]["username"] if "username" in data["data"]["user"] else None
|
return data["data"]["user"]["username"] if data["data"]["user"] is not None else None
|
||||||
|
|
||||||
def login(self, user: str, passwd: str) -> None:
|
def login(self, user: str, passwd: str) -> None:
|
||||||
"""Log in to instagram with given username and password and internally store session object"""
|
"""Log in to instagram with given username and password and internally store session object"""
|
||||||
@ -1334,30 +1334,22 @@ class Instaloader:
|
|||||||
def get_feed_posts(self) -> Iterator[Post]:
|
def get_feed_posts(self) -> Iterator[Post]:
|
||||||
"""Get Posts of the user's feed."""
|
"""Get Posts of the user's feed."""
|
||||||
|
|
||||||
data = self.get_json('', params={'__a': 1})
|
if not self.is_logged_in:
|
||||||
|
return
|
||||||
|
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3", {})["data"]
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if "graphql" in data:
|
feed = data["user"]["edge_web_feed_timeline"]
|
||||||
is_edge = True
|
yield from (Post(self, edge["node"]) for edge in feed["edges"]
|
||||||
feed = data["graphql"]["user"]["edge_web_feed_timeline"]
|
if not edge["node"]["__typename"] == "GraphSuggestedUserFeedUnit")
|
||||||
elif "data" in data:
|
|
||||||
is_edge = True
|
|
||||||
feed = data["data"]["user"]["edge_web_feed_timeline"]
|
|
||||||
else:
|
|
||||||
is_edge = False
|
|
||||||
feed = data["feed"]["media"]
|
|
||||||
|
|
||||||
if is_edge:
|
|
||||||
yield from (Post(self, edge["node"]) for edge in feed["edges"])
|
|
||||||
else:
|
|
||||||
yield from (Post(self, node) for node in feed["nodes"])
|
|
||||||
|
|
||||||
if not feed["page_info"]["has_next_page"]:
|
if not feed["page_info"]["has_next_page"]:
|
||||||
break
|
break
|
||||||
data = self.graphql_query(17863003771166879, {'fetch_media_item_count': 12,
|
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3",
|
||||||
|
{'fetch_media_item_count': 12,
|
||||||
'fetch_media_item_cursor': feed["page_info"]["end_cursor"],
|
'fetch_media_item_cursor': feed["page_info"]["end_cursor"],
|
||||||
'fetch_comment_count': 4,
|
'fetch_comment_count': 4,
|
||||||
'fetch_like': 10})
|
'fetch_like': 10,
|
||||||
|
'has_stories': False})["data"]
|
||||||
|
|
||||||
def download_feed_posts(self, max_count: int = None, fast_update: bool = False,
|
def download_feed_posts(self, max_count: int = None, fast_update: bool = False,
|
||||||
filter_func: Optional[Callable[[Post], bool]] = None) -> None:
|
filter_func: Optional[Callable[[Post], bool]] = None) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user