1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 04:02:32 +01:00

[tumblr] add 'fallback-*' options (#2957)

specifically 'fallback-delay' and 'fallback-retries'
and change default number of retries to 2 (down from 3)
This commit is contained in:
Mike Fährmann 2022-10-26 13:53:45 +02:00
parent 0e5d2e128b
commit 7c6af27eb8
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 25 additions and 2 deletions

View File

@ -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

View File

@ -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)