summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/moebooru.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2023-10-03 18:31:58 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2023-10-03 18:31:58 -0400
commitb8758ecd073910ce3220b2e68399147b425c37b8 (patch)
treed6aee20213508c8f425cbacb3d714367eca904c5 /gallery_dl/extractor/moebooru.py
parente2f67519f8c1750a71aab3dc56b8345fff21bac5 (diff)
New upstream version 1.26.0.upstream/1.26.0
Diffstat (limited to 'gallery_dl/extractor/moebooru.py')
-rw-r--r--gallery_dl/extractor/moebooru.py127
1 files changed, 20 insertions, 107 deletions
diff --git a/gallery_dl/extractor/moebooru.py b/gallery_dl/extractor/moebooru.py
index 0ef0a32..145dd51 100644
--- a/gallery_dl/extractor/moebooru.py
+++ b/gallery_dl/extractor/moebooru.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2020-2022 Mike Fährmann
+# Copyright 2020-2023 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
@@ -92,92 +92,12 @@ BASE_PATTERN = MoebooruExtractor.update({
})
-class MoebooruPostExtractor(MoebooruExtractor):
- subcategory = "post"
- archive_fmt = "{id}"
- pattern = BASE_PATTERN + r"/post/show/(\d+)"
- test = (
- ("https://yande.re/post/show/51824", {
- "content": "59201811c728096b2d95ce6896fd0009235fe683",
- "options": (("tags", True),),
- "keyword": {
- "tags_artist": "sasaki_tamaru",
- "tags_circle": "softhouse_chara",
- "tags_copyright": "ouzoku",
- "tags_general": str,
- },
- }),
- ("https://konachan.com/post/show/205189", {
- "content": "674e75a753df82f5ad80803f575818b8e46e4b65",
- "options": (("tags", True),),
- "keyword": {
- "tags_artist": "patata",
- "tags_character": "clownpiece",
- "tags_copyright": "touhou",
- "tags_general": str,
- },
- }),
- ("https://yande.re/post/show/993156", {
- "content": "fed722bd90f48de41ec163692befc701056e2b1e",
- "options": (("notes", True),),
- "keyword": {
- "notes": [
- {
- "id": 7096,
- "x" : 90,
- "y" : 626,
- "width" : 283,
- "height": 529,
- "body" : "Please keep this as a secret for me!!",
- },
- {
- "id": 7095,
- "x" : 900,
- "y" : 438,
- "width" : 314,
- "height": 588,
- "body" : "The facts that I love playing games",
- },
- ],
- },
- }),
- ("https://lolibooru.moe/post/show/281305/", {
- "content": "a331430223ffc5b23c31649102e7d49f52489b57",
- "options": (("notes", True),),
- "keyword": {
- "notes": list,
- },
- }),
- ("https://konachan.net/post/show/205189"),
- ("https://www.sakugabooru.com/post/show/125570"),
- ("https://lolibooru.moe/post/show/287835"),
- )
-
- def __init__(self, match):
- MoebooruExtractor.__init__(self, match)
- self.post_id = match.group(match.lastindex)
-
- def posts(self):
- params = {"tags": "id:" + self.post_id}
- return self.request(self.root + "/post.json", params=params).json()
-
-
class MoebooruTagExtractor(MoebooruExtractor):
subcategory = "tag"
directory_fmt = ("{category}", "{search_tags}")
archive_fmt = "t_{search_tags}_{id}"
- pattern = BASE_PATTERN + r"/post\?(?:[^&#]*&)*tags=([^&#]+)"
- test = (
- ("https://yande.re/post?tags=ouzoku+armor", {
- "content": "59201811c728096b2d95ce6896fd0009235fe683",
- }),
- ("https://konachan.com/post?tags=patata", {
- "content": "838cfb815e31f48160855435655ddf7bfc4ecb8d",
- }),
- ("https://konachan.net/post?tags=patata"),
- ("https://www.sakugabooru.com/post?tags=nichijou"),
- ("https://lolibooru.moe/post?tags=ruu_%28tksymkw%29"),
- )
+ pattern = BASE_PATTERN + r"/post\?(?:[^&#]*&)*tags=([^&#]*)"
+ example = "https://yande.re/post?tags=TAG"
def __init__(self, match):
MoebooruExtractor.__init__(self, match)
@@ -197,17 +117,7 @@ class MoebooruPoolExtractor(MoebooruExtractor):
directory_fmt = ("{category}", "pool", "{pool}")
archive_fmt = "p_{pool}_{id}"
pattern = BASE_PATTERN + r"/pool/show/(\d+)"
- test = (
- ("https://yande.re/pool/show/318", {
- "content": "2a35b9d6edecce11cc2918c6dce4de2198342b68",
- }),
- ("https://konachan.com/pool/show/95", {
- "content": "cf0546e38a93c2c510a478f8744e60687b7a8426",
- }),
- ("https://konachan.net/pool/show/95"),
- ("https://www.sakugabooru.com/pool/show/54"),
- ("https://lolibooru.moe/pool/show/239"),
- )
+ example = "https://yande.re/pool/show/12345"
def __init__(self, match):
MoebooruExtractor.__init__(self, match)
@@ -221,25 +131,28 @@ class MoebooruPoolExtractor(MoebooruExtractor):
return self._pagination(self.root + "/post.json", params)
+class MoebooruPostExtractor(MoebooruExtractor):
+ subcategory = "post"
+ archive_fmt = "{id}"
+ pattern = BASE_PATTERN + r"/post/show/(\d+)"
+ example = "https://yande.re/post/show/12345"
+
+ def __init__(self, match):
+ MoebooruExtractor.__init__(self, match)
+ self.post_id = match.group(match.lastindex)
+
+ def posts(self):
+ params = {"tags": "id:" + self.post_id}
+ return self.request(self.root + "/post.json", params=params).json()
+
+
class MoebooruPopularExtractor(MoebooruExtractor):
subcategory = "popular"
directory_fmt = ("{category}", "popular", "{scale}", "{date}")
archive_fmt = "P_{scale[0]}_{date}_{id}"
pattern = BASE_PATTERN + \
r"/post/popular_(by_(?:day|week|month)|recent)(?:\?([^#]*))?"
- test = (
- ("https://yande.re/post/popular_by_month?month=6&year=2014", {
- "count": 40,
- }),
- ("https://yande.re/post/popular_recent"),
- ("https://konachan.com/post/popular_by_month?month=11&year=2010", {
- "count": 20,
- }),
- ("https://konachan.com/post/popular_recent"),
- ("https://konachan.net/post/popular_recent"),
- ("https://www.sakugabooru.com/post/popular_recent"),
- ("https://lolibooru.moe/post/popular_recent"),
- )
+ example = "https://yande.re/post/popular_by_month?year=YYYY&month=MM"
def __init__(self, match):
MoebooruExtractor.__init__(self, match)