feat(scrape-range): add chapter range scraping for admin users

Adds FromChapter/ToChapter fields to orchestrator.Config and skips out-of-range
chapters in processBook. Exposes POST /scrape/book/range Go endpoint and a
matching UI proxy at /api/scrape/range. The book detail page now shows admins
a range input (from/to chapter) and a per-chapter 'scrape from here up' button.
This commit is contained in:
Admin
2026-03-05 14:00:50 +05:00
parent 97e7a8dc02
commit a54d8d43aa
4 changed files with 251 additions and 30 deletions

View File

@@ -45,6 +45,14 @@ type Config struct {
// that one book instead of walking the full catalogue.
SingleBookURL string
// FromChapter, when > 0, skips chapters with number < FromChapter.
// Only effective in single-book mode.
FromChapter int
// ToChapter, when > 0, skips chapters with number > ToChapter.
// Only effective in single-book mode. 0 means "no upper limit".
ToChapter int
// OnProgress is called periodically with the current progress counters.
// It is always called on completion (success or failure). May be nil.
OnProgress func(p Progress)
@@ -204,6 +212,15 @@ func (o *Orchestrator) Run(ctx context.Context) error {
// Enqueue chapter jobs.
for _, ref := range refs {
// Apply chapter range filter (only in single-book mode when set).
if o.cfg.FromChapter > 0 && ref.Number < o.cfg.FromChapter {
chaptersSkipped.Add(1)
continue
}
if o.cfg.ToChapter > 0 && ref.Number > o.cfg.ToChapter {
chaptersSkipped.Add(1)
continue
}
select {
case <-ctx.Done():
return