1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-10-26 22:22:30 +02:00

Alleviate #449 by catching bad metadata response

Instead of ungracefully failing with a TypeError, the Post is now skipped with
an error message containing the invalid JSON.
This commit is contained in:
Alexander Graf 2020-04-10 11:57:36 +02:00
parent c56657855d
commit 57d2ce9538

View File

@ -134,6 +134,12 @@ class Post:
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._rhx_gis_str = pic_json.get('rhx_gis')
if self._full_metadata_dict is None:
# issue #449
self._context.error("Fetching Post metadata failed (issue #449). "
"The following data has been returned:\n"
+ json.dumps(pic_json['entry_data'], indent=2))
raise BadResponseException("Fetching Post metadata failed.")
if self.shortcode != self._full_metadata_dict['shortcode']:
self._node.update(self._full_metadata_dict)
raise PostChangedException