Fix anonymous fetch of profile posts (#2533)

Co-authored-by: Alexander Graf <17130992+aandergr@users.noreply.github.com>
This commit is contained in:
Samuele Mazzi
2025-11-08 22:07:58 +01:00
committed by GitHub
co-authored by Alexander Graf
parent 813621026c
commit 64908788d3
+26 -11
View File
@@ -1197,18 +1197,33 @@ class Profile:
:rtype: NodeIterator[Post]""" :rtype: NodeIterator[Post]"""
self._obtain_metadata() self._obtain_metadata()
logged_in = self._context.is_logged_in
return NodeIterator( return NodeIterator(
context = self._context, context=self._context,
edge_extractor = lambda d: d['data']['xdt_api__v1__feed__user_timeline_graphql_connection'], edge_extractor=(
node_wrapper = lambda n: Post.from_iphone_struct(self._context, n), (lambda d: d["data"]["xdt_api__v1__feed__user_timeline_graphql_connection"])
query_variables = {'data': { if logged_in
'count': 12, 'include_relationship_info': True, else (lambda d: d["data"]["user"]["edge_owner_to_timeline_media"])
'latest_besties_reel_media': True, 'latest_reel_media': True}, ),
'username': self.username}, node_wrapper=(
query_referer = 'https://www.instagram.com/{0}/'.format(self.username), (lambda n: Post.from_iphone_struct(self._context, n))
is_first = Profile._make_is_newest_checker(), if logged_in
doc_id = '7898261790222653', else (lambda n: Post(self._context, n, self))
query_hash = None, ),
query_variables={
"data": {
"count": 12,
"include_relationship_info": True,
"latest_besties_reel_media": True,
"latest_reel_media": True,
},
**({"username": self.username} if logged_in else {"id": self.userid}),
},
query_referer="https://www.instagram.com/{0}/".format(self.username),
is_first=Profile._make_is_newest_checker(),
doc_id="7898261790222653" if logged_in else "7950326061742207",
query_hash=None,
first_data=(None if logged_in else self._metadata("edge_owner_to_timeline_media")),
) )
def get_saved_posts(self) -> NodeIterator[Post]: def get_saved_posts(self) -> NodeIterator[Post]: