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:
parent
c56657855d
commit
57d2ce9538
@ -134,6 +134,12 @@ class Post:
|
|||||||
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.get('rhx_gis')
|
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']:
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user