Files
bookhoard/bruno/NewDevDBSetup/ScanAllLibraries.yml
john-okeefe 58a30b6561 chore(bruno): add multi-library dev setup with scan-all and folder requests
Update NewDevDBSetup collection to create Ebook, Comic, and Manga
libraries with separate IDs (ebook_library_id, comic_library_id,
manga_library_id) instead of a single library_id.

- Fix CreateComicLibrary and CreateMangaLibrary to use correct
  names, descriptions, and types instead of duplicating Ebook values
- Update NewDB.sh to run the full setup sequence: register user,
  create all three libraries, add folders, then scan all
- Add AddEbookLibraryFolder, AddComicLibraryFolder, and
  AddMangaLibraryFolder requests with per-type subfolder paths
- Add ScanAllLibraries request using bru.sendRequest() to scan
  each library sequentially via the /api/scanner/scan endpoint
- Update Get Libraries (Admin) to save all three library IDs
- Update List Media Items requests to use ebook_library_id
- Rename library_id to ebook_library_id in Create Library and
  Add Library Folder requests
- Add comic_library_id and manga_library_id to environment
2026-04-19 18:08:39 -04:00

71 lines
2.2 KiB
YAML

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".