diff --git a/gallery_dl/extractor/gelbooru_v02.py b/gallery_dl/extractor/gelbooru_v02.py index a0658083..da87b8f1 100644 --- a/gallery_dl/extractor/gelbooru_v02.py +++ b/gallery_dl/extractor/gelbooru_v02.py @@ -31,6 +31,7 @@ class GelbooruV02Extractor(booru.BooruExtractor): if self.category == "realbooru": self._file_url = self._file_url_realbooru + self._tags = self._tags_realbooru def _api_request(self, params): url = self.api_root + "/index.php?page=dapi&s=post&q=index" @@ -85,14 +86,6 @@ class GelbooruV02Extractor(booru.BooruExtractor): post["date"] = text.parse_datetime( post["created_at"], "%a %b %d %H:%M:%S %z %Y") - def _file_url_realbooru(self, post): - url = post["file_url"] - md5 = post["md5"] - if md5 not in post["preview_url"] or url.count("/") == 5: - url = "{}/images/{}/{}/{}.{}".format( - self.root, md5[0:2], md5[2:4], md5, url.rpartition(".")[2]) - return url - def _html(self, post): return self.request("{}/index.php?page=post&s=view&id={}".format( self.root, post["id"])).text @@ -128,6 +121,24 @@ class GelbooruV02Extractor(booru.BooruExtractor): "body" : text.unescape(text.remove_html(extr(">", ""))), }) + def _file_url_realbooru(self, post): + url = post["file_url"] + md5 = post["md5"] + if md5 not in post["preview_url"] or url.count("/") == 5: + url = "{}/images/{}/{}/{}.{}".format( + self.root, md5[0:2], md5[2:4], md5, url.rpartition(".")[2]) + return url + + def _tags_realbooru(self, post, page): + tag_container = text.extr(page, 'id="tagLink"', '') + tags = collections.defaultdict(list) + pattern = re.compile( + r'