info: name: ScanAllLibraries type: http seq: 9 http: method: GET url: "{{base_url}}/api/scanner/watch/status" auth: inherit runtime: scripts: - type: before-request code: |- async function scanAllLibraries() { try { await bru.runRequest("library/Get Libraries (Admin)"); const baseUrl = bru.getEnvVar("base_url"); const token = bru.getEnvVar("token"); const libraries = [ { name: "Ebook", id: bru.getEnvVar("ebook_library_id") }, { name: "Comic", id: bru.getEnvVar("comic_library_id") }, { name: "Manga", id: bru.getEnvVar("manga_library_id") }, ].filter(lib => lib.id); if (libraries.length === 0) { console.log("No library IDs found. Run Get Libraries (Admin) first."); return; } for (const lib of libraries) { await bru.sendRequest( { method: "POST", url: `${baseUrl}/api/scanner/scan`, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, data: { library_id: lib.id, force: true, }, }, function (err, res) { if (err) { console.error(`Failed to scan ${lib.name}:`, err); return; } console.log(`${libraries.length} libraries queued for scanning`); }) } } catch (error) { console.error("Error in scan all:", error.message); } } await scanAllLibraries(); settings: encodeUrl: true timeout: 0 followRedirects: true maxRedirects: 5 docs: |- ## Scan All Libraries Fetches all libraries via "Get Libraries (Admin)" and triggers a background scan for each one sequentially. Uses `bru.runRequest()` to get libraries, then loops through each calling `POST /api/scanner/scan` with `{ library_id, force: true }`. Job IDs are logged to console. The last job_id is saved to the environment for use with "Get Scan Status".