parent
3528e8d19b
commit
749ff60639
@ -796,7 +796,7 @@ class Instaloader:
|
|||||||
for node in self.context.graphql_node_list("df0dcc250c2b18d9fd27c5581ef33c7c",
|
for node in self.context.graphql_node_list("df0dcc250c2b18d9fd27c5581ef33c7c",
|
||||||
{}, 'https://www.instagram.com/explore/',
|
{}, 'https://www.instagram.com/explore/',
|
||||||
lambda d: d['data']['user']['edge_web_discover_media'],
|
lambda d: d['data']['user']['edge_web_discover_media'],
|
||||||
data['rhx_gis']))
|
data.get('rhx_gis')))
|
||||||
|
|
||||||
def get_hashtag_posts(self, hashtag: str) -> Iterator[Post]:
|
def get_hashtag_posts(self, hashtag: str) -> Iterator[Post]:
|
||||||
"""Get Posts associated with a #hashtag."""
|
"""Get Posts associated with a #hashtag."""
|
||||||
|
@ -530,6 +530,6 @@ class InstaloaderContext:
|
|||||||
# At the moment, rhx_gis seems to be required for anonymous requests only. By returning None when logged
|
# At the moment, rhx_gis seems to be required for anonymous requests only. By returning None when logged
|
||||||
# in, we can save the root_rhx_gis lookup query.
|
# in, we can save the root_rhx_gis lookup query.
|
||||||
return None
|
return None
|
||||||
if not self._root_rhx_gis:
|
if self._root_rhx_gis is None:
|
||||||
self._root_rhx_gis = self.get_json('', {})['rhx_gis']
|
self._root_rhx_gis = self.get_json('', {}).get('rhx_gis', '')
|
||||||
return self._root_rhx_gis
|
return self._root_rhx_gis or None
|
||||||
|
@ -132,7 +132,7 @@ class Post:
|
|||||||
if not self._full_metadata_dict:
|
if not self._full_metadata_dict:
|
||||||
pic_json = self._context.get_json("p/{0}/".format(self.shortcode), params={})
|
pic_json = self._context.get_json("p/{0}/".format(self.shortcode), params={})
|
||||||
self._full_metadata_dict = pic_json['entry_data']['PostPage'][0]['graphql']['shortcode_media']
|
self._full_metadata_dict = pic_json['entry_data']['PostPage'][0]['graphql']['shortcode_media']
|
||||||
self._rhx_gis_str = pic_json['rhx_gis']
|
self._rhx_gis_str = pic_json.get('rhx_gis')
|
||||||
if self.shortcode != self._full_metadata_dict['shortcode']:
|
if self.shortcode != self._full_metadata_dict['shortcode']:
|
||||||
self._node.update(self._full_metadata_dict)
|
self._node.update(self._full_metadata_dict)
|
||||||
raise PostChangedException
|
raise PostChangedException
|
||||||
@ -144,9 +144,8 @@ class Post:
|
|||||||
return self._full_metadata_dict
|
return self._full_metadata_dict
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _rhx_gis(self) -> str:
|
def _rhx_gis(self) -> Optional[str]:
|
||||||
self._obtain_metadata()
|
self._obtain_metadata()
|
||||||
assert self._rhx_gis_str is not None
|
|
||||||
return self._rhx_gis_str
|
return self._rhx_gis_str
|
||||||
|
|
||||||
def _field(self, *keys) -> Any:
|
def _field(self, *keys) -> Any:
|
||||||
@ -454,6 +453,7 @@ class Profile:
|
|||||||
self._context = context
|
self._context = context
|
||||||
self._has_public_story = None # type: Optional[bool]
|
self._has_public_story = None # type: Optional[bool]
|
||||||
self._node = node
|
self._node = node
|
||||||
|
self._has_full_metadata = False
|
||||||
self._rhx_gis = None
|
self._rhx_gis = None
|
||||||
self._iphone_struct_ = None
|
self._iphone_struct_ = None
|
||||||
if 'iphone_struct' in node:
|
if 'iphone_struct' in node:
|
||||||
@ -514,10 +514,11 @@ class Profile:
|
|||||||
|
|
||||||
def _obtain_metadata(self):
|
def _obtain_metadata(self):
|
||||||
try:
|
try:
|
||||||
if not self._rhx_gis:
|
if not self._has_full_metadata:
|
||||||
metadata = self._context.get_json('{}/'.format(self.username), params={})
|
metadata = self._context.get_json('{}/'.format(self.username), params={})
|
||||||
self._node = metadata['entry_data']['ProfilePage'][0]['graphql']['user']
|
self._node = metadata['entry_data']['ProfilePage'][0]['graphql']['user']
|
||||||
self._rhx_gis = metadata['rhx_gis']
|
self._has_full_metadata = True
|
||||||
|
self._rhx_gis = metadata.get('rhx_gis')
|
||||||
except (QueryReturnedNotFoundException, KeyError) as err:
|
except (QueryReturnedNotFoundException, KeyError) as err:
|
||||||
raise ProfileNotExistsException('Profile {} does not exist.'.format(self.username)) from err
|
raise ProfileNotExistsException('Profile {} does not exist.'.format(self.username)) from err
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user