summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/realbooru.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/realbooru.py')
-rw-r--r--gallery_dl/extractor/realbooru.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/gallery_dl/extractor/realbooru.py b/gallery_dl/extractor/realbooru.py
new file mode 100644
index 0000000..6d89151
--- /dev/null
+++ b/gallery_dl/extractor/realbooru.py
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2019 Mike Fährmann
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+
+"""Extractors for https://realbooru.com/"""
+
+from . import booru
+
+
+class RealbooruExtractor(booru.XmlParserMixin,
+ booru.GelbooruPageMixin,
+ booru.BooruExtractor):
+ """Base class for realbooru extractors"""
+ category = "realbooru"
+ api_url = "https://realbooru.com/index.php"
+ post_url = "https://realbooru.com/index.php?page=post&s=view&id={}"
+ pool_url = "https://realbooru.com/index.php?page=pool&s=show&id={}"
+
+ def __init__(self, match):
+ super().__init__(match)
+ self.params.update({"page": "dapi", "s": "post", "q": "index"})
+
+
+class RealbooruTagExtractor(booru.TagMixin, RealbooruExtractor):
+ """Extractor for images from realbooru.com based on search-tags"""
+ pattern = (r"(?:https?://)?(?:www\.)?realbooru\.com/(?:index\.php)?"
+ r"\?page=post&s=list&tags=(?P<tags>[^&#]+)")
+ test = ("https://realbooru.com/index.php?page=post&s=list&tags=wine", {
+ "count": 64,
+ })
+
+
+class RealbooruPoolExtractor(booru.GelbooruPoolMixin, RealbooruExtractor):
+ """Extractor for image-pools from realbooru.com"""
+ pattern = (r"(?:https?://)?(?:www\.)?realbooru\.com/(?:index\.php)?"
+ r"\?page=pool&s=show&id=(?P<pool>\d+)")
+ test = ("https://realbooru.com/index.php?page=pool&s=show&id=1", {
+ "count": 3,
+ })
+
+
+class RealbooruPostExtractor(booru.PostMixin, RealbooruExtractor):
+ """Extractor for single images from realbooru.com"""
+ pattern = (r"(?:https?://)?(?:www\.)?realbooru\.com/(?:index\.php)?"
+ r"\?page=post&s=view&id=(?P<post>\d+)")
+ test = ("https://realbooru.com/index.php?page=post&s=view&id=668483", {
+ "url": "2421b5b0e15d5e20f9067090a8b0fd4114d3e7d9",
+ "content": "7f5873ce3b6cd295ea2e81fcb49583098ea9c8da",
+ "options": (("tags", True),),
+ "keyword": {
+ "tags_general" : str,
+ "tags_metadata": "tagme",
+ "tags_model" : "jennifer_lawrence",
+ },
+ })