Gelbooru: tag jobs fail with JSONDecodeError after 1,200 posts (API refuses offsets above 1,000)
まだ誰も着手していません。
評価
調査の方向性
Start by reading the Gelbooru download and chunk-resume path in monloader, then trace how it invokes gallery-dl with an offset; the issue points to gallery-dl's _pagination in gallery_dl/extractor/gelbooru.py for the API behavior. Reproduce with --range 1201-1202 and compare with --range 1001-1002. Done when resuming a later chunk avoids the API's offset limit, or reports a clear error instead of JSONDecodeError, with the behavior covered by a regression test.
索引モデルが issue の本文から書いたものです。
説明
Version: monloader v1.14.1 (Docker image ghcr.io/monbooru/monloader:v1.14.1), gallery-dl 1.32.19 in the image.
What happens
A watch on a Gelbooru tag with more than 1,200 posts downloads the first 6 chunks of 200 posts. The chunk that starts at offset 1200 then fails each time, also after a retry:
WARN queue: job 202 failed: download_failed: JSONDecodeError Expecting value: line 1 column 1 (char 0)
WARN queue: job 203 failed: download_failed: JSONDecodeError Expecting value: line 1 column 1 (char 0)
Cause
The Gelbooru API does not accept a start offset above 1,000 posts. For a deeper pid, it returns HTTP 200 with a plain-text body instead of JSON. The requests include the API key and user ID:
page=dapi&s=post&q=index&json=1&tags=1girl&limit=100&pid=10 -> JSON, 100 posts
page=dapi&s=post&q=index&json=1&tags=1girl&limit=100&pid=11 -> "Too deep! Pull it back some. Holy fuck."
page=dapi&s=post&q=index&json=1&tags=1girl&limit=100&pid=12 -> same text
The result is the same for each tag that I tried. With limit=50, pid=21 (offset 1050) also gets this text.
gallery-dl uses pid only for its first request. After that, it pages with id:<{last post id}, which has no depth limit (_pagination in gallery_dl/extractor/gelbooru.py). When a monloader chunk resumes at an offset, gallery-dl starts at pid = offset // 100:
- The chunk at offset 1000 starts at
pid=10. This works, and the rest of the chunk usesid:<. - The chunk at offset 1200 starts at
pid=12. Gelbooru sends the text, and gallery-dl cannot decode it.
To reproduce in the container:
gallery-dl --config /config/gallery-dl.json --simulate --range 1201-1202 'https://gelbooru.com/index.php?page=post&s=list&tags=1girl'
--range 1001-1002 works. --range 1201-1202 fails with the JSONDecodeError.
Workaround
Add the tag again with id:< and the ID of the oldest downloaded post, for example tags=1girl+id%3A%3C12345678. The chunks of that URL start at pid=0 again.
Each URL gets 1,200 posts at most. For a tag with 2,500 posts, I needed 3 URLs: the tag, then 2 id:< URLs. The first id:< URL also stopped at offset 1200 with the same error.
Possible fix
For Gelbooru, resume a chunk from the ID of the last post of the previous chunk (id:<N), not from an offset. If that is not possible, show a clear message for an offset above 1,000 instead of the JSONDecodeError.
- 主要言語
- Go
- スター
- 18
- フォーク
- 6
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
monbooru/monloader のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 56/100
-
難易度 3/5 半日 初心者へのやさしさ 72/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
monbooru/monloader の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
OneBusAway/watchdog#470 ·
メンテナーはふだん 1 日以内に返信
-
area: session
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
charmbracelet/crush#4484 ·
メンテナーはふだん 1 日以内に返信
-
[Resource]: Hearthオープンresource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
hesreallyhim/awesome-claude-code#3713 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
expr-lang/expr#1037 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
provider-key submission
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
opentofu/registry#6740 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信