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

[deviantart] add 'wait-min' option

This commit is contained in:
Mike Fährmann 2018-07-14 11:52:21 +02:00
parent a6fe2bb594
commit 00032b828c
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 18 additions and 2 deletions

View File

@ -333,6 +333,18 @@ Description The ``refresh_token`` value you get from linking your
=========== =====
extractor.deviantart.wait-min
-----------------------------
=========== =====
Type ``int``
Default ``0``
Description Minimum wait time in seconds before any API request.
Note: This value will internally be rounded up
to the next power of 2.
=========== =====
extractor.exhentai.original
---------------------------
=========== =====

View File

@ -14,6 +14,7 @@ from ..cache import cache, memcache
import itertools
import datetime
import time
import math
import re
@ -422,7 +423,10 @@ class DeviantartAPI():
self.session = extractor.session
self.log = extractor.log
self.headers = {}
self.delay = -1
delay = extractor.config("wait-min", 0)
self.delay = math.ceil(math.log2(delay)) if delay >= 1 else -1
self.delay_min = max(2, self.delay)
self.mature = extractor.config("mature", "true")
if not isinstance(self.mature, str):
@ -551,7 +555,7 @@ class DeviantartAPI():
status = response.status_code
if 200 <= status < 400:
if self.delay > 1:
if self.delay > self.delay_min:
self.delay -= 1
return data
elif expect_error: