[e621] fix applying request_interval_min (#2533)
Setting this property after calling Extractor.__init__() has no effect.
This commit is contained in:
@@ -603,18 +603,21 @@ class BaseExtractor(Extractor):
|
||||
|
||||
def __init__(self, match):
|
||||
if not self.category:
|
||||
for index, group in enumerate(match.groups()):
|
||||
if group is not None:
|
||||
if index:
|
||||
self.category, self.root = self.instances[index-1]
|
||||
if not self.root:
|
||||
self.root = text.root_from_url(match.group(0))
|
||||
else:
|
||||
self.root = group
|
||||
self.category = group.partition("://")[2]
|
||||
break
|
||||
self._init_category(match)
|
||||
Extractor.__init__(self, match)
|
||||
|
||||
def _init_category(self, match):
|
||||
for index, group in enumerate(match.groups()):
|
||||
if group is not None:
|
||||
if index:
|
||||
self.category, self.root = self.instances[index-1]
|
||||
if not self.root:
|
||||
self.root = text.root_from_url(match.group(0))
|
||||
else:
|
||||
self.root = group
|
||||
self.category = group.partition("://")[2]
|
||||
break
|
||||
|
||||
@classmethod
|
||||
def update(cls, instances):
|
||||
extra_instances = config.get(("extractor",), cls.basecategory)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"""Extractors for https://danbooru.donmai.us/ and other Danbooru instances"""
|
||||
|
||||
from .common import BaseExtractor, Message
|
||||
from ..version import __version__
|
||||
from .. import text
|
||||
import datetime
|
||||
|
||||
@@ -22,16 +23,7 @@ class DanbooruExtractor(BaseExtractor):
|
||||
per_page = 200
|
||||
|
||||
def __init__(self, match):
|
||||
BaseExtractor.__init__(self, match)
|
||||
|
||||
self.ugoira = self.config("ugoira", False)
|
||||
self.external = self.config("external", False)
|
||||
self.extended_metadata = self.config("metadata", False)
|
||||
|
||||
username, api_key = self._get_auth_info()
|
||||
if username:
|
||||
self.log.debug("Using HTTP Basic Auth for user '%s'", username)
|
||||
self.session.auth = (username, api_key)
|
||||
self._init_category(match)
|
||||
|
||||
instance = INSTANCES.get(self.category) or {}
|
||||
iget = instance.get
|
||||
@@ -43,6 +35,17 @@ class DanbooruExtractor(BaseExtractor):
|
||||
self.request_interval_min = iget("request-interval-min", 0.0)
|
||||
self._pools = iget("pools")
|
||||
|
||||
BaseExtractor.__init__(self, match)
|
||||
|
||||
self.ugoira = self.config("ugoira", False)
|
||||
self.external = self.config("external", False)
|
||||
self.extended_metadata = self.config("metadata", False)
|
||||
|
||||
username, api_key = self._get_auth_info()
|
||||
if username:
|
||||
self.log.debug("Using HTTP Basic Auth for user '%s'", username)
|
||||
self.session.auth = (username, api_key)
|
||||
|
||||
def request(self, url, **kwargs):
|
||||
kwargs["headers"] = self.headers
|
||||
return BaseExtractor.request(self, url, **kwargs)
|
||||
@@ -144,7 +147,8 @@ INSTANCES = {
|
||||
"e621": {
|
||||
"root": None,
|
||||
"pattern": r"e(?:621|926)\.net",
|
||||
"headers": {"User-Agent": "gallery-dl/1.14.0 (by mikf)"},
|
||||
"headers": {"User-Agent": "gallery-dl/{} (by mikf)".format(
|
||||
__version__)},
|
||||
"pools": "sort",
|
||||
"page-limit": 750,
|
||||
"per-page": 320,
|
||||
|
||||
Reference in New Issue
Block a user