summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/gelbooru_v02.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2024-06-06 02:40:15 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2024-06-06 02:40:15 -0400
commit1c28712d865e30ed752988ba0b6944882250b665 (patch)
treee5d5083a418f5c19616cb940c090c2dfb646d3cb /gallery_dl/extractor/gelbooru_v02.py
parent6e662211019a89caec44de8a57c675872b0b5498 (diff)
New upstream version 1.27.0.upstream/1.27.0
Diffstat (limited to 'gallery_dl/extractor/gelbooru_v02.py')
-rw-r--r--gallery_dl/extractor/gelbooru_v02.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/gallery_dl/extractor/gelbooru_v02.py b/gallery_dl/extractor/gelbooru_v02.py
index 7ab6d02..8d8b8ad 100644
--- a/gallery_dl/extractor/gelbooru_v02.py
+++ b/gallery_dl/extractor/gelbooru_v02.py
@@ -25,7 +25,7 @@ class GelbooruV02Extractor(booru.BooruExtractor):
self.api_root = self.config_instance("api_root") or self.root
if self.category == "realbooru":
- self._file_url = self._file_url_realbooru
+ self.items = self._items_realbooru
self._tags = self._tags_realbooru
def _api_request(self, params):
@@ -124,6 +124,35 @@ class GelbooruV02Extractor(booru.BooruExtractor):
self.root, md5[0:2], md5[2:4], md5, url.rpartition(".")[2])
return url
+ def _items_realbooru(self):
+ from .common import Message
+ data = self.metadata()
+
+ for post in self.posts():
+ try:
+ html = self._html(post)
+ fallback = post["file_url"]
+ url = post["file_url"] = text.rextract(
+ html, 'href="', '"', html.index(">Original<"))[0]
+ except Exception:
+ self.log.debug("Unable to fetch download URL for post %s "
+ "(md5: %s)", post.get("id"), post.get("md5"))
+ continue
+
+ text.nameext_from_url(url, post)
+ post.update(data)
+ self._prepare(post)
+ self._tags(post, html)
+
+ path = url.rpartition("/")[0]
+ post["_fallback"] = (
+ "{}/{}.{}".format(path, post["md5"], post["extension"]),
+ fallback,
+ )
+
+ yield Message.Directory, post
+ yield Message.Url, url, post
+
def _tags_realbooru(self, post, page):
tag_container = text.extr(page, 'id="tagLink"', '</div>')
tags = collections.defaultdict(list)