[gelbooru] support 'all' and empty tag (#5076)

pull/5094/head
Mike Fährmann 8 months ago
parent a416d4c3d5
commit 93b4120e77
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -118,7 +118,7 @@ class GelbooruBase():
class GelbooruTagExtractor(GelbooruBase,
gelbooru_v02.GelbooruV02TagExtractor):
"""Extractor for images from gelbooru.com based on search-tags"""
pattern = BASE_PATTERN + r"page=post&s=list&tags=([^&#]+)"
pattern = BASE_PATTERN + r"page=post&s=list&tags=([^&#]*)"
example = "https://gelbooru.com/index.php?page=post&s=list&tags=TAG"

@ -190,7 +190,7 @@ class GelbooruV02TagExtractor(GelbooruV02Extractor):
subcategory = "tag"
directory_fmt = ("{category}", "{search_tags}")
archive_fmt = "t_{search_tags}_{id}"
pattern = BASE_PATTERN + r"/index\.php\?page=post&s=list&tags=([^&#]+)"
pattern = BASE_PATTERN + r"/index\.php\?page=post&s=list&tags=([^&#]*)"
example = "https://safebooru.org/index.php?page=post&s=list&tags=TAG"
def __init__(self, match):
@ -202,6 +202,8 @@ class GelbooruV02TagExtractor(GelbooruV02Extractor):
return {"search_tags": self.tags}
def posts(self):
if self.tags == "all":
self.tags = ""
return self._pagination({"tags": self.tags})

@ -15,6 +15,20 @@ __tests__ = (
"#count" : 5,
},
{
"#url" : "https://gelbooru.com/index.php?page=post&s=list&tags=all",
"#category": ("booru", "gelbooru", "tag"),
"#class" : gelbooru.GelbooruTagExtractor,
"#range" : "1-3",
"#count" : 3,
},
{
"#url" : "https://gelbooru.com/index.php?page=post&s=list&tags=",
"#category": ("booru", "gelbooru", "tag"),
"#class" : gelbooru.GelbooruTagExtractor,
},
{
"#url" : "https://gelbooru.com/index.php?page=post&s=list&tags=meiya_neon",
"#category": ("booru", "gelbooru", "tag"),

@ -16,6 +16,20 @@ __tests__ = (
"#sha1_content": "e5ad4c5bf241b1def154958535bef6c2f6b733eb",
},
{
"#url" : "https://safebooru.org/index.php?page=post&s=list&tags=all",
"#category": ("gelbooru_v02", "safebooru", "tag"),
"#class" : gelbooru_v02.GelbooruV02TagExtractor,
"#range" : "1-3",
"#count" : 3,
},
{
"#url" : "https://safebooru.org/index.php?page=post&s=list&tags=",
"#category": ("gelbooru_v02", "safebooru", "tag"),
"#class" : gelbooru_v02.GelbooruV02TagExtractor,
},
{
"#url" : "https://safebooru.org/index.php?page=pool&s=show&id=11",
"#category": ("gelbooru_v02", "safebooru", "pool"),

Loading…
Cancel
Save