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
@@ -4,7 +4,7 @@
<span class="loading-text">Loading audiobook...</span>
</div>
} @else {
<div class="audiobook-reader">
<div class="audiobook-player">
<!-- Hidden audio element -->
<audio
#audioElement
@@ -53,7 +53,7 @@ $border-color: rgba(255, 255, 255, 0.1);
}
// Main container
.audiobook-reader {
.audiobook-player {
display: flex;
flex-direction: column;
height: 100vh;
@@ -436,9 +436,10 @@ $border-color: rgba(255, 255, 255, 0.1);
.audio-details {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: 1.25rem;
padding: 1rem 1rem 0;
padding: 1rem;
color: $text-tertiary;
font-size: 0.8rem;
background: rgba(255, 255, 255, 0.03);
@@ -23,7 +23,7 @@ import {AuthService} from '../../../shared/service/auth.service';
import {API_CONFIG} from '../../../core/config/api-config';
@Component({
selector: 'app-audiobook-reader',
selector: 'app-audiobook-player',
standalone: true,
imports: [
CommonModule,
@@ -35,10 +35,10 @@ import {API_CONFIG} from '../../../core/config/api-config';
SelectButton,
Menu
],
templateUrl: './audiobook-reader.component.html',
styleUrls: ['./audiobook-reader.component.scss']
templateUrl: './audiobook-player.component.html',
styleUrls: ['./audiobook-player.component.scss']
})
export class AudiobookReaderComponent implements OnInit, OnDestroy {
export class AudiobookPlayerComponent implements OnInit, OnDestroy {
@ViewChild('audioElement') audioElement!: ElementRef<HTMLAudioElement>;
private destroy$ = new Subject<void>();
@@ -161,10 +161,10 @@ export class AudiobookReaderComponent implements OnInit, OnDestroy {
}
}
// Load cover URLs
// Load cover URLs - prefer stored audiobook cover, fall back to embedded, then book cover
const token = this.authService.getInternalAccessToken() || this.authService.getOidcAccessToken();
this.bookCoverUrl = `${API_CONFIG.BASE_URL}/api/v1/media/cover/${this.bookId}?token=${encodeURIComponent(token || '')}`;
this.coverUrl = this.audiobookService.getEmbeddedCoverUrl(this.bookId);
this.bookCoverUrl = `${API_CONFIG.BASE_URL}/api/v1/media/book/${this.bookId}/cover?token=${encodeURIComponent(token || '')}`;
this.coverUrl = `${API_CONFIG.BASE_URL}/api/v1/media/book/${this.bookId}/audiobook-cover?token=${encodeURIComponent(token || '')}`;
this.isLoading = false;
@@ -789,7 +789,13 @@ export class AudiobookReaderComponent implements OnInit, OnDestroy {
}
onCoverError(): void {
if (this.coverUrl !== this.bookCoverUrl) {
// Fallback chain: stored audiobook cover -> embedded cover -> book cover
const embeddedCoverUrl = this.audiobookService.getEmbeddedCoverUrl(this.bookId);
if (this.coverUrl && !this.coverUrl.includes('/audiobook/') && this.coverUrl !== this.bookCoverUrl) {
// First fallback: try embedded cover from file
this.coverUrl = embeddedCoverUrl;
} else if (this.coverUrl !== this.bookCoverUrl) {
// Second fallback: try book cover
this.coverUrl = this.bookCoverUrl;
} else {
this.coverUrl = undefined;
@@ -1,3 +1,3 @@
export * from './audiobook-reader.component';
export * from './audiobook-player.component';
export * from './audiobook.service';
export * from './audiobook.model';