gelbooru: re-add background prefetch for batch API fast path only
When _batch_api_works is True (Gelbooru proper with auth, persisted from a prior session's probe), search() fires prefetch_batch in the background. The batch tag API covers the entire page's tags in 1-2 requests during the time between grid render and user click — the cache is warm before the info panel opens, so categories appear instantly with no flash of flat tags. Gated on _batch_api_works is True (not None, not False): - Gelbooru proper: prefetches (batch API known good) - Rule34: skips (batch_api_works = False, persisted) - Safebooru.org: skips (no auth → fetcher skips batch capability) Rule34 / Safebooru.org / Moebooru stay on-demand: the ~200ms per-click HTML scrape is unavoidable for those sites because their only path is per-post page fetching, which can't be batched.
This commit is contained in:
parent
403c099bed
commit
57a19f87ba
@ -81,6 +81,18 @@ class GelbooruClient(BooruClient):
|
|||||||
created_at=_parse_date(item.get("created_at")),
|
created_at=_parse_date(item.get("created_at")),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
# Background prefetch ONLY when the batch tag API is known to
|
||||||
|
# work (persisted probe result = True, i.e. Gelbooru proper
|
||||||
|
# with auth). One request covers all tags for the page, so the
|
||||||
|
# cache is warm before the user clicks. Rule34/Safebooru.org
|
||||||
|
# skip this (batch_api_works is False or None) — their only
|
||||||
|
# path is per-post HTML which runs on click.
|
||||||
|
if (
|
||||||
|
self.category_fetcher is not None
|
||||||
|
and self.category_fetcher._batch_api_works is True
|
||||||
|
):
|
||||||
|
import asyncio
|
||||||
|
asyncio.create_task(self.category_fetcher.prefetch_batch(posts))
|
||||||
return posts
|
return posts
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user