diff --git a/docs/configuration.rst b/docs/configuration.rst index 44853e3b..92a56443 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -2274,6 +2274,19 @@ Description use an extra HTTP request to find the URL to its full-resolution version. +extractor.tumblr.ratelimit +-------------------------- +Type + ``string`` +Default + ``"abort"`` +Description + Selects how to handle exceeding the daily API rate limit. + + * ``"abort"``: Raise an error and stop extraction + * ``"wait"``: Wait until rate limit reset + + extractor.tumblr.reblogs ------------------------ Type diff --git a/gallery_dl/extractor/tumblr.py b/gallery_dl/extractor/tumblr.py index 4a130e87..6f538811 100644 --- a/gallery_dl/extractor/tumblr.py +++ b/gallery_dl/extractor/tumblr.py @@ -464,10 +464,8 @@ class TumblrAPI(oauth.OAuth1API): # daily rate limit if response.headers.get("x-ratelimit-perday-remaining") == "0": + self.log.info("Daily API rate limit exceeded") reset = response.headers.get("x-ratelimit-perday-reset") - t = (datetime.now() + timedelta(seconds=float(reset))).time() - - self.log.error("Daily API rate limit exceeded") api_key = self.api_key or self.session.auth.consumer_key if api_key == self.API_KEY: @@ -477,6 +475,11 @@ class TumblrAPI(oauth.OAuth1API): "ter/docs/configuration.rst#extractortumblra" "pi-key--api-secret") + if self.extractor.config("ratelimit") == "wait": + self.extractor.wait(seconds=reset) + return self._call(blog, endpoint, params) + + t = (datetime.now() + timedelta(seconds=float(reset))).time() raise exception.StopExtraction( "Aborting - Rate limit will reset at %s", "{:02}:{:02}:{:02}".format(t.hour, t.minute, t.second))