From 7c6af27eb8ba193683436f24eb572581c1d1fcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 26 Oct 2022 13:53:45 +0200 Subject: [PATCH] [tumblr] add 'fallback-*' options (#2957) specifically 'fallback-delay' and 'fallback-retries' and change default number of retries to 2 (down from 3) --- docs/configuration.rst | 21 +++++++++++++++++++++ gallery_dl/extractor/tumblr.py | 6 ++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 3986d766..fa076227 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -2402,6 +2402,27 @@ Description You can use ``"all"`` instead of listing all types separately. +extractor.tumblr.fallback-delay +------------------------------- +Type + ``float`` +Default + ``120.0`` +Description + Number of seconds to wait between retries + for fetching full-resolution images. + + +extractor.tumblr.fallback-retries +--------------------------------- +Type + ``integer`` +Default + ``2`` +Description + Number of retries for fetching full-resolution images. + + extractor.twibooru.api-key -------------------------- Type diff --git a/gallery_dl/extractor/tumblr.py b/gallery_dl/extractor/tumblr.py index 324a3c6e..5451f6e0 100644 --- a/gallery_dl/extractor/tumblr.py +++ b/gallery_dl/extractor/tumblr.py @@ -49,6 +49,8 @@ class TumblrExtractor(Extractor): self.reblogs = self.config("reblogs", True) self.external = self.config("external", False) self.original = self.config("original", True) + self.fallback_delay = self.config("fallback-delay", 120.0) + self.fallback_retries = self.config("fallback-retries", 2) if len(self.types) == 1: self.api.posts_type = next(iter(self.types)) @@ -250,8 +252,8 @@ class TumblrExtractor(Extractor): return updated, (resized == updated) def _original_image_fallback(self, url, post_id): - for _ in range(3): - self.sleep(120, "image token") + for _ in range(self.fallback_retries): + self.sleep(self.fallback_delay, "image token") yield self._update_image_token(url)[0] self.log.warning("Unable to fetch higher-resolution " "version of %s (%s)", url, post_id)