Audiobook enhancement (#2611)

* Audiobook enhancement

* Fix choppy virtual scroller with mixed audiobook/ebook cards by using uniform heights

* Fix audiobook cover regeneration for combined books and improve error messages

* Fix cover extraction when attaching audiobook files during rescan

* Set audiobookCoverUpdatedOn for cache busting when generating cover

* Add support for regenerating covers from specific book files

* Fix Continue Reading/Listening scrollers to filter by actual progress instead of primary file type

* Show ebook cover and open ebook reader in Continue Reading scroller for combined books

* Prevent read status from being downgraded when saving audiobook progress

* Fix BookCoverServiceTest to match updated regenerateCover method signature
---------

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-02-05 13:33:08 -07:00
committed by GitHub
co-authored by acx10
parent 92d1334f25
commit d38271de9c
121 changed files with 5078 additions and 909 deletions
@@ -155,6 +155,60 @@
}
</div>
</div>
<div class="option-item allowed-formats-option">
<div class="option-label">
<span>Allowed formats</span>
<i
class="pi pi-question-circle info-icon"
pTooltip="Select which book formats this library should accept. Files of other formats will be ignored during scans."
tooltipPosition="right"
></i>
</div>
<div class="allowed-formats-container">
<div class="allow-all-toggle">
<p-checkbox
[(ngModel)]="allowAllFormats"
[binary]="true"
inputId="allowAll"
(onChange)="onAllowAllFormatsChange()"
/>
<label for="allowAll" class="allow-all-label">Allow all formats</label>
</div>
@if (!allowAllFormats) {
<div class="format-checkboxes">
@for (format of allBookFormats; track format.type) {
<div class="format-checkbox-item" [class.has-warning]="getFormatWarning(format.type)">
<p-checkbox
[ngModel]="isFormatSelected(format.type)"
[binary]="true"
[inputId]="'format-' + format.type"
(onChange)="onFormatCheckboxChange(format.type, $event.checked)"
/>
<label [for]="'format-' + format.type" class="format-checkbox-label">
{{ format.label }}
</label>
@if (getFormatWarning(format.type); as warning) {
<i
class="pi pi-exclamation-triangle warning-icon"
[pTooltip]="warning"
tooltipPosition="top"
></i>
}
</div>
}
</div>
@if (hasAnyFormatWarning()) {
<div class="format-warning-message">
<i class="pi pi-info-circle"></i>
<span>Deselected formats with existing books will not be affected, but won't appear in future scans</span>
</div>
}
}
</div>
</div>
</div>
</section>
</div>
@@ -2,7 +2,7 @@
max-width: 90vw;
display: flex;
flex-direction: column;
max-height: 85vh;
max-height: 90vh;
background: var(--card-background);
border: 1px solid var(--border-color);
border-radius: 12px;
@@ -88,7 +88,7 @@
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 1.125rem;
margin-bottom: 0.75rem;
font-size: 0.85rem;
font-weight: 600;
text-transform: uppercase;
@@ -408,7 +408,8 @@
--p-toggleswitch-checked-hover-background: var(--p-green-600);
}
&.format-priority-option {
&.format-priority-option,
&.allowed-formats-option {
flex-direction: column;
align-items: flex-start;
}
@@ -434,6 +435,78 @@
}
}
// Allowed formats
.allowed-formats-container {
display: flex;
flex-direction: column;
gap: 0.875rem;
width: 100%;
}
.allow-all-toggle {
display: flex;
align-items: center;
gap: 0.5rem;
.allow-all-label {
font-size: 0.875rem;
color: var(--text-color);
cursor: pointer;
}
}
.format-checkboxes {
display: flex;
flex-wrap: wrap;
gap: 0.75rem 1.25rem;
padding: 0.75rem;
background: var(--card-background);
border: 1px solid var(--border-color);
border-radius: 6px;
}
.format-checkbox-item {
display: flex;
align-items: center;
gap: 0.375rem;
min-width: 100px;
.format-checkbox-label {
font-size: 0.8rem;
color: var(--text-color);
cursor: pointer;
}
.warning-icon {
font-size: 0.75rem;
color: var(--p-orange-400);
margin-left: 0.25rem;
}
&.has-warning {
.format-checkbox-label {
color: var(--p-orange-400);
}
}
}
.format-warning-message {
display: flex;
align-items: flex-start;
gap: 0.5rem;
padding: 0.625rem 0.75rem;
background: rgba(234, 179, 8, 0.1);
border: 1px solid var(--p-orange-400);
border-radius: 6px;
font-size: 0.8rem;
color: var(--p-orange-400);
i {
flex-shrink: 0;
margin-top: 0.125rem;
}
}
// Format chips
.format-chips {
display: flex;
@@ -16,12 +16,13 @@ import {DialogLauncherService} from '../../shared/services/dialog-launcher.servi
import {switchMap} from 'rxjs/operators';
import {map} from 'rxjs';
import {CdkDragDrop, DragDropModule, moveItemInArray} from '@angular/cdk/drag-drop';
import {Checkbox} from 'primeng/checkbox';
@Component({
selector: 'app-library-creator',
standalone: true,
templateUrl: './library-creator.component.html',
imports: [FormsModule, InputText, ToggleSwitch, Tooltip, Button, IconDisplayComponent, DragDropModule],
imports: [FormsModule, InputText, ToggleSwitch, Tooltip, Button, IconDisplayComponent, DragDropModule, Checkbox],
styleUrl: './library-creator.component.scss'
})
export class LibraryCreatorComponent implements OnInit {
@@ -34,6 +35,9 @@ export class LibraryCreatorComponent implements OnInit {
editModeLibraryName: string = '';
watch: boolean = false;
formatPriority: {type: BookType, label: string}[] = [];
allowAllFormats: boolean = true;
selectedAllowedFormats: Set<BookType> = new Set();
formatCounts: Record<string, number> = {};
readonly allBookFormats: {type: BookType, label: string}[] = [
{type: 'EPUB', label: 'EPUB'},
@@ -55,13 +59,14 @@ export class LibraryCreatorComponent implements OnInit {
ngOnInit(): void {
this.initializeFormatPriority();
this.initializeAllowedFormats();
const data = this.dynamicDialogConfig?.data;
if (data?.mode === 'edit') {
this.mode = data.mode;
this.library = this.libraryService.findLibraryById(data.libraryId);
if (this.library) {
const {name, icon, iconType, paths, watch, formatPriority} = this.library;
const {name, icon, iconType, paths, watch, formatPriority, allowedFormats} = this.library;
this.chosenLibraryName = name;
this.editModeLibraryName = name;
@@ -84,6 +89,19 @@ export class LibraryCreatorComponent implements OnInit {
}
});
}
if (allowedFormats && allowedFormats.length > 0) {
this.allowAllFormats = false;
this.selectedAllowedFormats = new Set(allowedFormats);
} else {
this.allowAllFormats = true;
this.selectedAllowedFormats = new Set(this.allBookFormats.map(f => f.type));
}
this.libraryService.getBookCountsByFormat(this.library.id!).subscribe(counts => {
this.formatCounts = counts;
});
this.folders = paths.map(path => path.path);
}
}
@@ -93,6 +111,43 @@ export class LibraryCreatorComponent implements OnInit {
this.formatPriority = [...this.allBookFormats];
}
private initializeAllowedFormats(): void {
this.selectedAllowedFormats = new Set(this.allBookFormats.map(f => f.type));
}
onAllowAllFormatsChange(): void {
if (this.allowAllFormats) {
this.selectedAllowedFormats = new Set(this.allBookFormats.map(f => f.type));
}
}
onFormatCheckboxChange(formatType: BookType, checked: boolean): void {
if (checked) {
this.selectedAllowedFormats.add(formatType);
} else {
this.selectedAllowedFormats.delete(formatType);
}
this.allowAllFormats = this.selectedAllowedFormats.size === this.allBookFormats.length;
}
isFormatSelected(formatType: BookType): boolean {
return this.selectedAllowedFormats.has(formatType);
}
getFormatWarning(formatType: BookType): string | null {
if (this.mode !== 'edit') return null;
const count = this.formatCounts[formatType];
if (count && count > 0 && !this.selectedAllowedFormats.has(formatType)) {
return `${count} existing book${count > 1 ? 's' : ''} will not appear in future scans`;
}
return null;
}
hasAnyFormatWarning(): boolean {
if (this.mode !== 'edit') return false;
return this.allBookFormats.some(f => this.getFormatWarning(f.type) !== null);
}
closeDialog(): void {
this.dynamicDialogRef.close();
}
@@ -161,7 +216,8 @@ export class LibraryCreatorComponent implements OnInit {
iconType: iconType,
paths: this.folders.map(folder => ({path: folder})),
watch: this.watch,
formatPriority: this.formatPriority.map(f => f.type)
formatPriority: this.formatPriority.map(f => f.type),
allowedFormats: this.allowAllFormats ? [] : Array.from(this.selectedAllowedFormats)
};
if (this.mode === 'edit') {