43 lines
1.7 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# 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.
"""Extract image-urls from https://danbooru.donmai.us/"""
2015-11-21 00:55:25 +01:00
from . import booru
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"
2015-11-21 00:55:25 +01:00
class DanbooruTagExtractor(DanbooruExtractor, booru.BooruTagExtractor):
"""Extract images from danbooru based on search-tags"""
2015-11-30 01:11:13 +01:00
subcategory = "tag"
2015-11-21 00:55:25 +01:00
pattern = [r"(?:https?://)?(?:www\.)?danbooru.donmai.us/posts\?(?:utf8=%E2%9C%93&)?tags=([^&]+)"]
2015-12-12 15:59:26 +01:00
test = [("https://danbooru.donmai.us/posts?tags=heath_ledger", {
"url": "a261c33f117c7395f0eac54091075e67c8e66fca",
})]
2015-11-21 00:55:25 +01:00
class DanbooruPoolExtractor(DanbooruExtractor, booru.BooruPoolExtractor):
"""Extract 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", {
"url": "db522c7f74d42ec1940fb23d1a58ed8edb65f9ae",
"keyword": "bf8256e88ac0d032808e9f5aa165c9a1fa7e451c",
})]
2015-11-21 00:55:25 +01:00
class DanbooruPostExtractor(DanbooruExtractor, booru.BooruPostExtractor):
"""Extract 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-12 15:59:26 +01:00
test = [("https://danbooru.donmai.us/posts/1534703", {
"url": "3a87a761dad69dfa038499aeacef679a3912816b",
"keyword": "0a2f4dd6b8384fcbc805302040234536895a2dc3",
})]