mirror of
https://github.com/mikf/gallery-dl.git
synced 2025-01-31 11:41:35 +01:00
[gelbooru] improve pagination logic for meta tags (#5478)
similar to 494acabd38fefdc8c1b482b584695aaa788f9112
This commit is contained in:
parent
4cf24f15c2
commit
257e9fb435
@ -51,19 +51,44 @@ class GelbooruBase():
|
||||
params["pid"] = self.page_start
|
||||
params["limit"] = self.per_page
|
||||
limit = self.per_page // 2
|
||||
pid = False
|
||||
|
||||
if "tags" in params:
|
||||
tags = params["tags"].split()
|
||||
op = "<"
|
||||
id = False
|
||||
|
||||
for tag in tags:
|
||||
if tag.startswith("sort:"):
|
||||
if tag == "sort:id:asc":
|
||||
op = ">"
|
||||
elif tag == "sort:id" or tag.startswith("sort:id:"):
|
||||
op = "<"
|
||||
else:
|
||||
pid = True
|
||||
elif tag.startswith("id:"):
|
||||
id = True
|
||||
|
||||
if not pid:
|
||||
if id:
|
||||
tag = "id:" + op
|
||||
tags = [t for t in tags if not t.startswith(tag)]
|
||||
tags = "{} id:{}".format(" ".join(tags), op)
|
||||
|
||||
while True:
|
||||
posts = self._api_request(params)
|
||||
|
||||
for post in posts:
|
||||
yield post
|
||||
yield from posts
|
||||
|
||||
if len(posts) < limit:
|
||||
return
|
||||
|
||||
if "pid" in params:
|
||||
del params["pid"]
|
||||
params["tags"] = "{} id:<{}".format(self.tags, post["id"])
|
||||
if pid:
|
||||
params["pid"] += 1
|
||||
else:
|
||||
if "pid" in params:
|
||||
del params["pid"]
|
||||
params["tags"] = tags + str(posts[-1]["id"])
|
||||
|
||||
def _pagination_html(self, params):
|
||||
url = self.root + "/index.php"
|
||||
|
@ -39,6 +39,22 @@ __tests__ = (
|
||||
"#sha1_url": "845a61aa1f90fb4ced841e8b7e62098be2e967bf",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://gelbooru.com/index.php?page=post&s=list&tags=id:>=67800+id:<=68000",
|
||||
"#comment" : "meta tags (#5478)",
|
||||
"#category": ("booru", "gelbooru", "tag"),
|
||||
"#class" : gelbooru.GelbooruTagExtractor,
|
||||
"#count" : 187,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://gelbooru.com/index.php?page=post&s=list&tags=id:>=67800+id:<=68000+sort:id:asc",
|
||||
"#comment" : "meta + sort tags (#5478)",
|
||||
"#category": ("booru", "gelbooru", "tag"),
|
||||
"#class" : gelbooru.GelbooruTagExtractor,
|
||||
"#count" : 187,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://gelbooru.com/index.php?page=pool&s=show&id=761",
|
||||
"#category": ("booru", "gelbooru", "pool"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user