2015-04-11 00:17:06 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-12-30 21:34:55 +01:00
|
|
|
|
2015-04-11 00:17:06 +02:00
|
|
|
# Copyright 2014, 2015 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.
|
2014-12-30 21:34:55 +01:00
|
|
|
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extract images from https://danbooru.donmai.us/"""
|
2014-12-30 21:34:55 +01:00
|
|
|
|
2015-11-21 00:55:25 +01:00
|
|
|
from . import booru
|
2014-12-30 21:34:55 +01:00
|
|
|
|
2015-11-21 00:55:25 +01:00
|
|
|
class DanbooruExtractor(booru.JSONBooruExtractor):
|
|
|
|
"""Base class for danbooru extractors"""
|
|
|
|
category = "danbooru"
|
|
|
|
api_url = "https://danbooru.donmai.us/posts.json"
|
2014-12-30 21:34:55 +01:00
|
|
|
|
2015-11-21 00:55:25 +01:00
|
|
|
class DanbooruTagExtractor(DanbooruExtractor, booru.BooruTagExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for images from danbooru based on search-tags"""
|
2015-11-30 01:11:13 +01:00
|
|
|
subcategory = "tag"
|
2015-12-22 03:10:52 +01:00
|
|
|
pattern = [(r"(?:https?://)?(?:www\.)?danbooru.donmai.us/posts"
|
|
|
|
r"\?(?:utf8=%E2%9C%93&)?tags=([^&]+)")]
|
|
|
|
test = [("https://danbooru.donmai.us/posts?tags=bonocho", {
|
2016-07-12 12:08:36 +02:00
|
|
|
"url": "fb730af3f5e15650e5d924ffcda54b9ef232b89b",
|
2015-12-22 03:10:52 +01:00
|
|
|
"content": "b196fb9f1668109d7774a0a82efea3ffdda07746",
|
2015-12-12 15:59:26 +01:00
|
|
|
})]
|
2014-12-30 21:34:55 +01:00
|
|
|
|
2015-11-21 00:55:25 +01:00
|
|
|
class DanbooruPoolExtractor(DanbooruExtractor, booru.BooruPoolExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for image-pools from danbooru"""
|
2015-11-30 01:11:13 +01:00
|
|
|
subcategory = "pool"
|
2015-11-21 00:55:25 +01:00
|
|
|
pattern = [r"(?:https?://)?(?:www\.)?danbooru.donmai.us/pools/(\d+)"]
|
2015-12-12 15:59:26 +01:00
|
|
|
test = [("https://danbooru.donmai.us/pools/7659", {
|
2016-07-12 12:08:36 +02:00
|
|
|
"url": "73c02ec3d67ffd46d489dd6cfd7b35fee053865c",
|
2015-12-22 03:10:52 +01:00
|
|
|
"content": "b16bab12bea5f7ea9e0a836bf8045f280e113d99",
|
2015-12-12 15:59:26 +01:00
|
|
|
})]
|
2015-11-20 20:24:15 +01:00
|
|
|
|
2015-11-21 00:55:25 +01:00
|
|
|
class DanbooruPostExtractor(DanbooruExtractor, booru.BooruPostExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for single images from danbooru"""
|
2015-11-30 01:11:13 +01:00
|
|
|
subcategory = "post"
|
2015-11-21 00:55:25 +01:00
|
|
|
pattern = [r"(?:https?://)?(?:www\.)?danbooru.donmai.us/posts/(\d+)"]
|
2015-12-22 03:10:52 +01:00
|
|
|
test = [("https://danbooru.donmai.us/posts/294929", {
|
2016-07-12 12:08:36 +02:00
|
|
|
"url": "9caa006a4d9eedbacbe030655ade0d3225399749",
|
2015-12-22 03:10:52 +01:00
|
|
|
"content": "5e255713cbf0a8e0801dc423563c34d896bb9229",
|
2015-12-12 15:59:26 +01:00
|
|
|
})]
|