[twitter] warn about suspended accounts etc (closes #1759)

This commit is contained in:
Mike Fährmann 2021-08-09 01:53:41 +02:00
parent a5de2244d4
commit 229498b8aa
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -726,21 +726,25 @@ class TwitterAPI():
if csrf_token:
self.headers["x-csrf-token"] = csrf_token
data = response.json()
if "errors" in data:
try:
msg = ", ".join(
'"' + error["message"] + '"'
for error in data["errors"]
)
except Exception:
msg = data["errors"]
if response.status_code < 400:
self.extractor.log.warning(msg)
if response.status_code < 400:
return response.json()
return data
if response.status_code == 429:
until = response.headers.get("x-rate-limit-reset")
seconds = None if until else 60
self.extractor.wait(until=until, seconds=seconds)
continue
try:
msg = ", ".join(
'"' + error["message"] + '"'
for error in response.json()["errors"]
)
except Exception:
msg = response.text
raise exception.StopExtraction(
"%s %s (%s)", response.status_code, response.reason, msg)