mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-21 18:22:30 +01:00
[bilibili] add workarounds for getting rate-limited (#6443)
- set 3-6 second request_interval by default - retry request after waiting 5 minutes
This commit is contained in:
parent
5bc3657c59
commit
e763efd36c
@ -394,7 +394,11 @@ Default
|
|||||||
* ``"2.0-4.0"``
|
* ``"2.0-4.0"``
|
||||||
``behance``, ``imagefap``, ``[Nijie]``
|
``behance``, ``imagefap``, ``[Nijie]``
|
||||||
* ``"3.0-6.0"``
|
* ``"3.0-6.0"``
|
||||||
``exhentai``, ``idolcomplex``, ``[reactor]``, ``readcomiconline``
|
``bilibili``,
|
||||||
|
``exhentai``,
|
||||||
|
``idolcomplex``,
|
||||||
|
``[reactor]``,
|
||||||
|
``readcomiconline``
|
||||||
* ``"6.0-6.1"``
|
* ``"6.0-6.1"``
|
||||||
``twibooru``
|
``twibooru``
|
||||||
* ``"6.0-12.0"``
|
* ``"6.0-12.0"``
|
||||||
|
@ -14,6 +14,7 @@ class BilibiliExtractor(Extractor):
|
|||||||
"""Base class for bilibili extractors"""
|
"""Base class for bilibili extractors"""
|
||||||
category = "bilibili"
|
category = "bilibili"
|
||||||
root = "https://www.bilibili.com"
|
root = "https://www.bilibili.com"
|
||||||
|
request_interval = (3.0, 6.0)
|
||||||
|
|
||||||
def _init(self):
|
def _init(self):
|
||||||
self.api = BilibiliAPI(self)
|
self.api = BilibiliAPI(self)
|
||||||
@ -102,6 +103,14 @@ class BilibiliAPI():
|
|||||||
|
|
||||||
def article(self, article_id):
|
def article(self, article_id):
|
||||||
url = "https://www.bilibili.com/opus/" + article_id
|
url = "https://www.bilibili.com/opus/" + article_id
|
||||||
response = self.extractor.request(url)
|
|
||||||
return util.json_loads(text.extr(
|
while True:
|
||||||
response.text, "window.__INITIAL_STATE__=", "};") + "}")
|
page = self.extractor.request(url).text
|
||||||
|
try:
|
||||||
|
return util.json_loads(text.extr(
|
||||||
|
page, "window.__INITIAL_STATE__=", "};") + "}")
|
||||||
|
except Exception:
|
||||||
|
if "window._riskdata_" not in page:
|
||||||
|
raise exception.StopExtraction(
|
||||||
|
"%s: Unable to extract INITIAL_STATE data", article_id)
|
||||||
|
self.extractor.wait(seconds=300)
|
||||||
|
Loading…
Reference in New Issue
Block a user