Resume paused scrapes from their cursor
This commit is contained in:
@@ -384,6 +384,28 @@ export class MediaService {
|
||||
this.engine.stop(id);
|
||||
}
|
||||
|
||||
/** Continue a paused scrape from its cursor with the same backend family. */
|
||||
async resumeScrape(scrapeId: string): Promise<ScrapeMeta | null> {
|
||||
const meta = this.engine.get(scrapeId);
|
||||
if (!meta) return null;
|
||||
|
||||
let backend: ScrapeBackend;
|
||||
if (meta.backend === "slopbot" && meta.guildId) {
|
||||
const available = await this.ensureSlopbot();
|
||||
const inGuild = this.bot?.guilds.cache.has(meta.guildId) ?? false;
|
||||
const fetcher = this.botFetcher;
|
||||
if (!available || !inGuild || !fetcher) {
|
||||
throw new Error("slopbot is not connected to that guild");
|
||||
}
|
||||
backend = new SlopbotBackend(fetcher);
|
||||
} else {
|
||||
backend = this.puppetBackend();
|
||||
}
|
||||
|
||||
this.deps.log?.(`resuming scrape ${scrapeId} from cursor ${meta.cursor ?? "start"}`);
|
||||
return this.engine.resume(scrapeId, backend);
|
||||
}
|
||||
|
||||
listScrapes(): ScrapeMeta[] {
|
||||
return this.engine.list();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user