Introduce multi-format book support, including audiobooks (#2486)

* fix: support reading alternative book formats using bookType query param

* feat: add streaming reader support for alternative EPUB formats

* refactor: extract tabs section into MetadataTabsComponent

* feat: implement per-file reading progress tracking

* feat: add configurable format priority with cascading fallback

* refactor: redesign library creator with single-page layout

* refactor: unify reading progress into ReadingProgressService

* refactor: improve delete options with clearer file format and book deletion

* refactor: improve book format matching with normalization and fuzzy fallback

* feat: add folder-based audiobook support with ZIP downloads and preparing state

* fix: display unique format types in metadata viewer

* refactor: auto-attach files to single book in folder during rescan

* feat: implement folder-centric book file grouping with fuzzy matching

* refactor: consolidate book grouping with organization mode support

* fix: use folder hash for folder-based audiobooks in auto-attach

* fix: delete only BookFileEntity on file removal, not entire book

* fix: set folderBased flag and correct file size for auto-attached audiobook folders

* fix: use count query to avoid lazy initialization in file delete handler

* fix: preserve book metadata when file is moved by detecting hash match

* fix: skip books with no files in restoration to avoid NPE

* fix: round all progress percentages to one decimal place before sending to UI

* style: improve library creator dialog spacing and layout

* fix: migrate FOLDER_AS_BOOK to BOOK_PER_FOLDER for backwards compatibility

* fix: FileMoveService now handles multi-file BookEntity properly

* style: redesign metadata-picker and file-mover UI components

* style: redesign file-naming-pattern UI and improve theme contrast

* style: relax spacing in library-creator component

* style: tighten directory-picker layout for consistency

* fix: PathPatternResolver now respects folderBased flag for audiobooks

* style: move checkmark column to left side and add pending status in file-mover

* refactor: consolidate BookFileType into BookType and add audiobook styling

* feat: show 'Continue Reading' button for in-progress books

* fix: preserve dots in folder names during grouping and prevent duplicate attachments

* style: reduce gap between download-all button and primary file section

* style: shorten 'Continue Reading' button to 'Read' on mobile

* feat: add DISK_TYPE config to disable file moves on network storage

* style: standardize settings pages with shared styles and consistent spacing

* style: revamp settings pages with modern card-based layouts

* style: revamp OPDS, auth, and task management settings layouts

* fix: update FileMoveService tests to include AppProperties parameter

* fix: derive BookFileType from extension when uploading additional book files

* feat: show format type and size in download button with dropdown for alternatives

* feat: add audiobook streaming player with HTTP Range support

* feat: add M4B chapter extraction and chapter navigation

* feat: add audiobook bookmarks and sleep timer

* refactor: split AudiobookReaderService into focused services

* feat: add Media Session API for background audio playback

* feat: display file extensions in format tags with distinct colors and add audiobook upload support

* feat: require bookFileId for viewer settings API

* fix: show split button for audiobooks with readable alternatives

* feat: improve reading sessions table with book type badges and better formatting

* feat: add audiobook play button in files tab

* feat: use file extension for format display and meaningful tab values

* feat: add extension field to BookFile DTO

* feat: use extension field for book card format pill

* fix: use mixed orientation for format priority drag-drop to support multi-line layout

* feat: add attach book files feature to consolidate single-file books

* fix: increase drag handle size for format priority chips

* fix: add missing BookFileRepository mock to BookServiceDeleteTests

* feat: add delete buttons to files tab and move shelf to other items menu

* feat: add physical books support for cataloging books without digital files

* refactor: redesign icon-picker component with improved styling

* refactor: redesign metadata-picker component with improved layout and alignment

* refactor: move Add Physical Book to top of library menu

* refactor: use p-autoComplete for authors/categories in add-physical-book dialog

* feat: add square cover search and display support for audiobooks

* fix: navigate to first page when opening unread ebooks

* fix: exclude API requests from service worker interception

* feat: support fileless books with automatic file attachment

* fix: bypass service worker for audiobook streaming requests

* refactor: remove alphabetical filter sorting, default to count, limit filters to 100

---------

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-27 10:12:50 -07:00
committed by GitHub
co-authored by acx10
parent c23e38b5a5
commit 3f334202b6
340 changed files with 23225 additions and 20727 deletions
@@ -2,7 +2,7 @@ import {Component, HostListener, inject, OnDestroy, OnInit} from '@angular/core'
import {ActivatedRoute, Router} from '@angular/router';
import {CommonModule} from '@angular/common';
import {forkJoin, Subject} from 'rxjs';
import {filter, first, takeUntil, timeout} from 'rxjs/operators';
import {filter, first, map, switchMap, takeUntil, timeout} from 'rxjs/operators';
import {PageTitleService} from "../../../shared/service/page-title.service";
import {CbxReaderService} from '../../book/service/cbx-reader.service';
import {BookService} from '../../book/service/book.service';
@@ -55,6 +55,8 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
bookType!: BookType;
bookId!: number;
bookFileId?: number;
altBookType?: string;
pages: number[] = [];
currentPage = 0;
isLoading = true;
@@ -129,34 +131,48 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
this.route.paramMap.subscribe((params) => {
this.isLoading = true;
this.bookId = +params.get('bookId')!;
this.altBookType = this.route.snapshot.queryParamMap.get('bookType') ?? undefined;
this.previousBookInSeries = null;
this.nextBookInSeries = null;
this.currentBook = null;
forkJoin([
this.bookService.getBookByIdFromAPI(this.bookId, false),
this.bookService.getBookSetting(this.bookId),
this.userService.getMyself()
]).subscribe({
next: ([book, bookSettings, myself]) => {
const userSettings = myself.userSettings;
this.bookType = book.bookType;
this.bookService.getBookByIdFromAPI(this.bookId, false).pipe(
switchMap((book) => {
// Use alternative bookType from query param if provided, otherwise use primary
this.bookType = (this.altBookType as BookType) ?? book.primaryFile?.bookType!;
this.currentBook = book;
// Determine which file ID to use for progress tracking
if (this.altBookType) {
const altFile = book.alternativeFormats?.find(f => f.bookType === this.altBookType);
this.bookFileId = altFile?.id;
} else {
this.bookFileId = book.primaryFile?.id;
}
return forkJoin([
this.bookService.getBookSetting(this.bookId, this.bookFileId!),
this.userService.getMyself()
]).pipe(map(([bookSettings, myself]) => ({ book, bookSettings, myself })));
})
).subscribe({
next: ({ book, bookSettings, myself }) => {
const userSettings = myself.userSettings;
this.pageTitle.setBookPageTitle(book);
const title = book.metadata?.title || book.fileName;
this.headerService.initialize(this.bookId, title, this.destroy$);
this.sidebarService.initialize(this.bookId, book, this.destroy$);
this.sidebarService.initialize(this.bookId, book, this.destroy$, this.altBookType);
if (book.metadata?.seriesName) {
this.loadSeriesNavigationAsync(book);
}
const pagesObservable = this.bookType === CbxReaderComponent.TYPE_PDF
? this.pdfReaderService.getAvailablePages(this.bookId)
: this.cbxReaderService.getAvailablePages(this.bookId);
? this.pdfReaderService.getAvailablePages(this.bookId, this.altBookType)
: this.cbxReaderService.getAvailablePages(this.bookId, this.altBookType);
pagesObservable.subscribe({
next: (pages) => {
@@ -728,8 +744,8 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
private getPageImageUrl(pageIndex: number): string {
return this.bookType === CbxReaderComponent.TYPE_PDF
? this.pdfReaderService.getPageImageUrl(this.bookId, this.pages[pageIndex])
: this.cbxReaderService.getPageImageUrl(this.bookId, this.pages[pageIndex]);
? this.pdfReaderService.getPageImageUrl(this.bookId, this.pages[pageIndex], this.altBookType)
: this.cbxReaderService.getPageImageUrl(this.bookId, this.pages[pageIndex], this.altBookType);
}
get infiniteScrollImageUrls(): string[] {
@@ -765,10 +781,10 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
: 0;
if (this.bookType === CbxReaderComponent.TYPE_CBX) {
this.bookService.saveCbxProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
this.bookService.saveCbxProgress(this.bookId, this.currentPage + 1, percentage, this.bookFileId).subscribe();
}
if (this.bookType === CbxReaderComponent.TYPE_PDF) {
this.bookService.savePdfProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
this.bookService.savePdfProgress(this.bookId, this.currentPage + 1, percentage, this.bookFileId).subscribe();
}
}