2015-04-11 00:39:26 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-12-22 16:23:41 +01:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
# Copyright 2014-2018 Mike Fährmann
|
2015-04-11 00:39:26 +02:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extract images from https://e621.net/"""
|
2015-04-11 00:39:26 +02:00
|
|
|
|
2015-11-21 01:56:49 +01:00
|
|
|
from . import booru
|
2015-04-11 00:39:26 +02:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-01-06 17:48:49 +01:00
|
|
|
class E621Extractor(booru.MoebooruPageMixin, booru.BooruExtractor):
|
2015-11-21 01:56:49 +01:00
|
|
|
"""Base class for e621 extractors"""
|
|
|
|
category = "e621"
|
|
|
|
api_url = "https://e621.net/post/index.json"
|
2018-07-01 22:28:52 +02:00
|
|
|
post_url = "https://e621.net/post/show/{}"
|
2018-01-03 23:52:01 +01:00
|
|
|
page_limit = 750
|
2015-11-21 01:56:49 +01:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
class E621TagExtractor(booru.TagMixin, E621Extractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for images from e621.net based on search-tags"""
|
2015-11-21 01:56:49 +01:00
|
|
|
pattern = [
|
2018-01-03 23:52:01 +01:00
|
|
|
r"(?:https?://)?(?:www\.)?e621\.net/post/index/\d+/(?P<tags>[^/?&#]+)",
|
|
|
|
r"(?:https?://)?(?:www\.)?e621\.net/post\?tags=(?P<tags>[^&#]+)",
|
|
|
|
]
|
|
|
|
test = [
|
|
|
|
("https://e621.net/post/index/1/anry", {
|
|
|
|
"url": "8021e5ea28d47c474c1ffc9bd44863c4d45700ba",
|
|
|
|
"content": "501d1e5d922da20ee8ff9806f5ed3ce3a684fd58",
|
|
|
|
}),
|
|
|
|
("https://e621.net/post?tags=anry", None),
|
2015-11-21 01:56:49 +01:00
|
|
|
]
|
2015-04-11 00:39:26 +02:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
class E621PoolExtractor(booru.PoolMixin, E621Extractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for image-pools from e621.net"""
|
2018-01-03 23:52:01 +01:00
|
|
|
pattern = [r"(?:https?://)?(?:www\.)?e621\.net/pool/show/(?P<pool>\d+)"]
|
2015-12-14 03:00:58 +01:00
|
|
|
test = [("https://e621.net/pool/show/73", {
|
|
|
|
"url": "842f2fb065c7c339486a9b1d689020b8569888ed",
|
2015-12-22 03:10:52 +01:00
|
|
|
"content": "c2c87b7a9150509496cddc75ccab08109922876a",
|
2015-12-14 03:00:58 +01:00
|
|
|
})]
|
2014-12-22 16:23:41 +01:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
class E621PostExtractor(booru.PostMixin, E621Extractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for single images from e621.net"""
|
2018-01-03 23:52:01 +01:00
|
|
|
pattern = [r"(?:https?://)?(?:www\.)?e621\.net/post/show/(?P<post>\d+)"]
|
2015-12-14 03:00:58 +01:00
|
|
|
test = [("https://e621.net/post/show/535", {
|
|
|
|
"url": "f7f78b44c9b88f8f09caac080adc8d6d9fdaa529",
|
2015-12-22 03:10:52 +01:00
|
|
|
"content": "66f46e96a893fba8e694c4e049b23c2acc9af462",
|
2018-07-01 22:28:52 +02:00
|
|
|
"options": (("tags", True),),
|
|
|
|
"keyword": {
|
|
|
|
"tags_artist": "anry",
|
|
|
|
"tags_general": str,
|
|
|
|
"tags_species": str,
|
|
|
|
},
|
2015-12-14 03:00:58 +01:00
|
|
|
})]
|
2017-08-26 23:08:52 +02:00
|
|
|
|
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
class E621PopularExtractor(booru.MoebooruPopularMixin, E621Extractor):
|
2017-08-26 23:08:52 +02:00
|
|
|
"""Extractor for popular images from 621.net"""
|
2018-01-03 23:52:01 +01:00
|
|
|
pattern = [r"(?:https?://)?(?:www\.)?e621\.net"
|
|
|
|
r"/post/popular_by_(?P<scale>day|week|month)"
|
|
|
|
r"(?:\?(?P<query>[^#]*))?"]
|
2017-08-31 15:09:18 +02:00
|
|
|
test = [("https://e621.net/post/popular_by_month?month=6&year=2013", {
|
2017-08-26 23:08:52 +02:00
|
|
|
"count": 32,
|
|
|
|
})]
|
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
def __init__(self, match):
|
|
|
|
super().__init__(match)
|
|
|
|
self.api_url = "https://e621.net/post/popular_by_{scale}.json".format(
|
|
|
|
scale=self.scale)
|