mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-06 07:59:43 +00:00
2.2 KiB
2.2 KiB
Promote File to Book Specification
Overview
This feature allows users to "promote" files from an existing book into a standalone book in the library. This is useful when a single library item incorrectly groups multiple separate books or files together. The feature has two mechanisms: a quick single-file context action, and a bulk "Split Book" Wizard.
UI Requirements
1. Single-File Promotion (Quick Action)
- Added to the "Library Files" table (
LibraryFilesTableRow.vue). - A new context menu item "Promote to book" is available for active files.
- Selecting it opens a confirmation prompt.
2. Multi-File Book Split (Wizard)
- A "Split Book" button added to the header of the "Library Files" table (
LibraryFilesTable.vue). - Opens
SplitBookModal.vue, passing the current library item files. - Displays a table of audio/ebook files with an input binding for "Book Number" (Default 1).
- Includes an "Assign 1 to N" quick action for automatically splitting every single file into its own standalone book.
- Submits an array of file assignments containing the target Book Number.
Backend Requirements
1. Single-File Promotion
- Endpoint:
POST /api/items/:id/file/:fileid/promote - Logic:
- Determine a new folder name based on the target filename.
- Create the target destination folder.
- Move the specified file.
- Detach record from the current database entry.
- Trigger
LibraryScanner.scan(library)to generate the standalone library item.
2. Multi-file Book Split
- Endpoint:
POST /api/items/:id/split - Request Body:
{ assignments: [{ ino: string, bookNumber: number }] } - Logic:
- Group payload assignments by
bookNumber(ignoring1since that designates the current book). - Iterate through groups. For each group
[Book 2, Book 3, etc]: a. Compute target folder path based on original directory +- Book [N]. b. Ensure custom directory is created. c. Iterate throughinotargets and migrate target resources. - Detach file payload records from existing library item.
- Emit completion via
SocketAuthority.libraryItemEmitter. - Call
LibraryScanner.scan(library)to construct the new entities sequentially.
- Group payload assignments by