improve 'extractor.request'

- add 'fatal' argument
- improve internal logic and flow
- raise known exception on error
- update exception hierarchy
This commit is contained in:
Mike Fährmann
2017-08-05 16:11:46 +02:00
parent dcd573806e
commit 915a0137de
12 changed files with 75 additions and 62 deletions

View File

@@ -135,12 +135,10 @@ class MastodonAPI():
"""Get an account's statuses"""
url = "{}/api/v1/accounts/{}/statuses?only_media=1".format(
self.root, account_id)
while True:
while url:
response = self.session.get(url)
yield from self._parse(response)
url = response.links.get("next", {}).get("url")
if not url:
break
@staticmethod
def _parse(response):