[booru] allow multiple 'url' keys (#5859)

pull/5870/head
Mike Fährmann 2 months ago
parent bf44add132
commit 6940ad0e72
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -4577,14 +4577,18 @@ Description
extractor.[booru].url
---------------------
Type
``string``
* ``string``
* ``list`` of ``strings``
Default
``"file_url"``
Example
``"preview_url"``
* ``"preview_url"``
* ``["sample_url", "preview_url", "file_url"}``
Description
Alternate field name to retrieve download URLs from.
When multiple names are given, download the first available one.
extractor.[manga-extractor].chapter-reverse
-------------------------------------------

@ -29,6 +29,10 @@ class BooruExtractor(BaseExtractor):
url_key = self.config("url")
if url_key:
if isinstance(url_key, (list, tuple)):
self._file_url = self._file_url_list
self._file_url_keys = url_key
else:
self._file_url = operator.itemgetter(url_key)
for post in self.posts():
@ -74,6 +78,11 @@ class BooruExtractor(BaseExtractor):
_file_url = operator.itemgetter("file_url")
def _file_url_list(self, post):
urls = (post[key] for key in self._file_url_keys if post.get(key))
post["_fallback"] = it = iter(urls)
return next(it)
def _prepare(self, post):
"""Prepare a 'post's metadata"""

Loading…
Cancel
Save