mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
[twitter] add 'ratelimit' option (#4251)
This commit is contained in:
parent
f86fdf64a6
commit
1bf9f52c99
@ -3183,6 +3183,19 @@ Description
|
||||
a quoted (original) Tweet when it sees the Tweet which quotes it.
|
||||
|
||||
|
||||
extractor.twitter.ratelimit
|
||||
---------------------------
|
||||
Type
|
||||
``string``
|
||||
Default
|
||||
``"wait"``
|
||||
Description
|
||||
Selects how to handle exceeding the API rate limit.
|
||||
|
||||
* ``"abort"``: Raise an error and stop extraction
|
||||
* ``"wait"``: Wait until rate limit reset
|
||||
|
||||
|
||||
extractor.twitter.replies
|
||||
-------------------------
|
||||
Type
|
||||
|
@ -1439,6 +1439,9 @@ class TwitterAPI():
|
||||
|
||||
if response.status_code == 429:
|
||||
# rate limit exceeded
|
||||
if self.extractor.config("ratelimit") == "abort":
|
||||
raise exception.StopExtraction("Rate limit exceeded")
|
||||
|
||||
until = response.headers.get("x-rate-limit-reset")
|
||||
seconds = None if until else 60
|
||||
self.extractor.wait(until=until, seconds=seconds)
|
||||
|
Loading…
Reference in New Issue
Block a user