diff --git a/InstagramAPI/InstagramAPI.py b/InstagramAPI/InstagramAPI.py index d4b7443..6e29913 100644 --- a/InstagramAPI/InstagramAPI.py +++ b/InstagramAPI/InstagramAPI.py @@ -36,6 +36,8 @@ # Issue 159, python3 import fix from .ImageUtils import getImageSize +from .exceptions import SentryBlockException + class InstagramAPI: API_URL = 'https://i.instagram.com/api/v1/' @@ -978,6 +980,10 @@ def SendRequest(self, endpoint, post=None, login=False): self.LastResponse = response self.LastJson = json.loads(response.text) print(self.LastJson) + if 'error_type' in self.LastJson and self.LastJson['error_type'] == 'sentry_block': + raise SentryBlockException(self.LastJson['message']) + except SentryBlockException: + raise except: pass return False diff --git a/InstagramAPI/exceptions.py b/InstagramAPI/exceptions.py new file mode 100644 index 0000000..18c2ffd --- /dev/null +++ b/InstagramAPI/exceptions.py @@ -0,0 +1,2 @@ +class SentryBlockException(Exception): + pass