From 205ef3ca024c7bfa89175f3e82b1761877ba825f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 20 Nov 2015 20:25:31 +0100 Subject: [PATCH] [danbooru] add single image/post extractor --- gallery_dl/extractor/danbooru.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gallery_dl/extractor/danbooru.py b/gallery_dl/extractor/danbooru.py index 36c2998f..a7124c49 100644 --- a/gallery_dl/extractor/danbooru.py +++ b/gallery_dl/extractor/danbooru.py @@ -60,3 +60,21 @@ class DanbooruPoolExtractor(JSONBooruExtractor): "category": self.info["category"], "pool": self.pool, } + +class DanbooruPostExtractor(JSONBooruExtractor): + """Extract single images""" + + info = { + "category": "danbooru", + "directory": ["{category}"], + "filename": "{category}_{id}_{md5}.{extension}", + } + pattern = [ + r"(?:https?://)?(?:www\.)?danbooru.donmai.us/posts/(\d+)", + ] + + def __init__(self, match): + JSONBooruExtractor.__init__(self) + self.api_url = "https://danbooru.donmai.us/posts.json" + self.post = match.group(1) + self.params = {"tags": "id:" + self.post}