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
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
info:
|
||||
name: AddComicLibraryFolder
|
||||
type: http
|
||||
seq: 6
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: "{{base_url}}/api/libraries/{{comic_library_id}}/folders"
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"folder_path": "{{library_folder}}/Comics"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Add Library Folder
|
||||
|
||||
Adds a new folder path to a library for media scanning and indexing.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries/{id}
|
||||
@@ -0,0 +1,53 @@
|
||||
info:
|
||||
name: AddEbookLibraryFolder
|
||||
type: http
|
||||
seq: 15
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: "{{base_url}}/api/libraries/{{ebook_library_id}}/folders"
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"folder_path": "{{library_folder}}/Ebooks"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: after-response
|
||||
code: |-
|
||||
function onResponse(res) {
|
||||
try {
|
||||
const responseBody = res.getBody();
|
||||
const id = responseBody.id;
|
||||
|
||||
if (id) {
|
||||
bru.setEnvVar("library_folder_id", id, { persist: true });
|
||||
console.log("Library Folder ID saved:", id);
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
console.log("No id found in response.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error in post-response script:", error.message);
|
||||
}
|
||||
}
|
||||
onResponse(res);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Add Library Folder
|
||||
|
||||
Adds a new folder path to a library for media scanning and indexing.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries/{id}
|
||||
@@ -0,0 +1,30 @@
|
||||
info:
|
||||
name: AddMangaLibraryFolder
|
||||
type: http
|
||||
seq: 7
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: "{{base_url}}/api/libraries/{{manga_library_id}}/folders"
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"folder_path": "{{library_folder}}/Manga"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Add Library Folder
|
||||
|
||||
Adds a new folder path to a library for media scanning and indexing.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries/{id}
|
||||
@@ -10,9 +10,9 @@ http:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"name": "My Ebook Library",
|
||||
"description": "A collection of technical books and novels",
|
||||
"type": "ebooks"
|
||||
"name": "My Comic Library",
|
||||
"description": "A collection of comics",
|
||||
"type": "comics"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
@@ -26,7 +26,7 @@ runtime:
|
||||
const id = responseBody.id;
|
||||
|
||||
if (id) {
|
||||
bru.setEnvVar("library_id", id, { persist: true });
|
||||
bru.setEnvVar("comic_library_id", id, { persist: true });
|
||||
console.log("Library ID saved:", id);
|
||||
}
|
||||
|
||||
@@ -44,40 +44,3 @@ settings:
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Create Library
|
||||
|
||||
Creates a new library for organizing media items.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Request Body:**
|
||||
- `name` (string, required): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string, required): Library type
|
||||
- `"ebooks"`: Electronic books
|
||||
- `"audiobooks"`: Audio books
|
||||
- `"videos"`: Video content
|
||||
- `"other"`: Other media types
|
||||
|
||||
**Response:** Library object
|
||||
- `id` (string): Library UUID
|
||||
- `name` (string): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string): Library type
|
||||
- `is_visible` (boolean): Library visibility status
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Library created successfully
|
||||
- 400: Invalid request data
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (insufficient permissions)
|
||||
- 409: Library name already exists
|
||||
- 500: Internal server error
|
||||
|
||||
@@ -26,7 +26,7 @@ runtime:
|
||||
const id = responseBody.id;
|
||||
|
||||
if (id) {
|
||||
bru.setEnvVar("library_id", id, { persist: true });
|
||||
bru.setEnvVar("ebook_library_id", id, { persist: true });
|
||||
console.log("Library ID saved:", id);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ http:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"name": "My Ebook Library",
|
||||
"description": "A collection of technical books and novels",
|
||||
"type": "ebooks"
|
||||
"name": "My Manga Library",
|
||||
"description": "A collection of manga",
|
||||
"type": "manga"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
@@ -26,7 +26,7 @@ runtime:
|
||||
const id = responseBody.id;
|
||||
|
||||
if (id) {
|
||||
bru.setEnvVar("library_id", id, { persist: true });
|
||||
bru.setEnvVar("manga_library_id", id, { persist: true });
|
||||
console.log("Library ID saved:", id);
|
||||
}
|
||||
|
||||
@@ -44,40 +44,3 @@ settings:
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Create Library
|
||||
|
||||
Creates a new library for organizing media items.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Request Body:**
|
||||
- `name` (string, required): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string, required): Library type
|
||||
- `"ebooks"`: Electronic books
|
||||
- `"audiobooks"`: Audio books
|
||||
- `"videos"`: Video content
|
||||
- `"other"`: Other media types
|
||||
|
||||
**Response:** Library object
|
||||
- `id` (string): Library UUID
|
||||
- `name` (string): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string): Library type
|
||||
- `is_visible` (boolean): Library visibility status
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Library created successfully
|
||||
- 400: Invalid request data
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (insufficient permissions)
|
||||
- 409: Library name already exists
|
||||
- 500: Internal server error
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
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".
|
||||
Reference in New Issue
Block a user