Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit c8f47b9

Browse files
committed
Merge branch 'master' of github.com:beichhor/python-instagram into beichhor-master
2 parents 5d8cd6a + f81532a commit c8f47b9

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

instagram/bind.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ def _do_api_request(self, url, method="GET", body=None, headers=None):
9999
except ValueError:
100100
raise InstagramClientError('Unable to parse response, not valid JSON.')
101101

102+
# Handle OAuthRateLimitExceeded from Instagram's Nginx which uses different format to documented api responses
103+
if not content_obj.has_key('meta'):
104+
if content_obj.get('code') == 420:
105+
error_message = content_obj.get('error_message') or "Your client is making too many request per second"
106+
raise InstagramAPIError(420, "Rate limited", error_message)
107+
raise InstagramAPIError(content_obj.has_key('code'), content_obj.has_key('error_type'), content_obj.has_key('error_message'))
108+
102109
api_responses = []
103110
status_code = content_obj['meta']['code']
104111
self.api.x_ratelimit_remaining = response.get("x-ratelimit-remaining",None)

0 commit comments

Comments
 (0)