summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/booru.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/booru.py')
-rw-r--r--gallery_dl/extractor/booru.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/gallery_dl/extractor/booru.py b/gallery_dl/extractor/booru.py
index cbd0e07..7e26f38 100644
--- a/gallery_dl/extractor/booru.py
+++ b/gallery_dl/extractor/booru.py
@@ -29,16 +29,21 @@ class BooruExtractor(BaseExtractor):
url_key = self.config("url")
if url_key:
- self._file_url = operator.itemgetter(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():
try:
url = self._file_url(post)
if url[0] == "/":
url = self.root + url
- except (KeyError, TypeError):
- self.log.debug("Unable to fetch download URL for post %s "
- "(md5: %s)", post.get("id"), post.get("md5"))
+ except Exception as exc:
+ self.log.debug("%s: %s", exc.__class__.__name__, exc)
+ self.log.warning("Unable to fetch download URL for post %s "
+ "(md5: %s)", post.get("id"), post.get("md5"))
continue
if fetch_html:
@@ -73,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"""