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:
+157
-48
@@ -7,6 +7,7 @@ import {Component, Input} from '@angular/core';
|
||||
export class CoverGeneratorComponent {
|
||||
@Input() title: string = '';
|
||||
@Input() author: string = '';
|
||||
@Input() isSquare: boolean = false;
|
||||
|
||||
private wrapText(text: string, maxLineLength: number): string[] {
|
||||
const words = text.split(' ');
|
||||
@@ -40,26 +41,159 @@ export class CoverGeneratorComponent {
|
||||
return text.substring(0, maxLength - 3) + '...';
|
||||
}
|
||||
|
||||
private calculateTitleFontSize(lineCount: number): number {
|
||||
if (lineCount <= 2) return 36;
|
||||
if (lineCount === 3) return 30;
|
||||
return 24;
|
||||
private escapeXml(text: string): string {
|
||||
return text
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
private calculateAuthorFontSize(lineCount: number): number {
|
||||
if (lineCount <= 2) return 28;
|
||||
return 22;
|
||||
private hashString(str: string): number {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const char = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + char;
|
||||
hash = hash & hash;
|
||||
}
|
||||
return Math.abs(hash);
|
||||
}
|
||||
|
||||
generateCover(): string {
|
||||
const width = 250;
|
||||
const height = this.isSquare ? 250 : 350;
|
||||
const hash = this.hashString(this.title + this.author);
|
||||
|
||||
if (this.isSquare) {
|
||||
return this.generateAudiobookCover(width, height, hash);
|
||||
} else {
|
||||
return this.generateEbookCover(width, height, hash);
|
||||
}
|
||||
}
|
||||
|
||||
private generateEbookCover(width: number, height: number, hash: number): string {
|
||||
const palettes = [
|
||||
{bg1: '#1a1a2e', bg2: '#16213e', accent: '#e94560', text: '#eaeaea', textSecondary: '#b8b8b8'},
|
||||
{bg1: '#2d3436', bg2: '#636e72', accent: '#74b9ff', text: '#ffffff', textSecondary: '#dfe6e9'},
|
||||
{bg1: '#0c3547', bg2: '#1a5276', accent: '#f39c12', text: '#ecf0f1', textSecondary: '#bdc3c7'},
|
||||
{bg1: '#1e3d59', bg2: '#17263a', accent: '#ffc13b', text: '#f5f0e1', textSecondary: '#c7b198'},
|
||||
{bg1: '#2c2c54', bg2: '#474787', accent: '#ff793f', text: '#f8f8f8', textSecondary: '#d1ccc0'},
|
||||
{bg1: '#1b262c', bg2: '#0f4c75', accent: '#3282b8', text: '#bbe1fa', textSecondary: '#8fbdd3'},
|
||||
];
|
||||
|
||||
const palette = palettes[hash % palettes.length];
|
||||
const {titleLines, authorLines, titleFontSize, authorFontSize} = this.processText(false);
|
||||
|
||||
const titleLineHeight = titleFontSize * 1.3;
|
||||
const titleStartY = 80;
|
||||
|
||||
const titleElements = titleLines.map((line, index) => {
|
||||
const y = titleStartY + (index * titleLineHeight);
|
||||
return `<text x="125" y="${y}" text-anchor="middle" font-family="Georgia, serif" font-weight="600" font-size="${titleFontSize}" fill="${palette.text}">${this.escapeXml(line)}</text>`;
|
||||
}).join('\n');
|
||||
|
||||
const authorLineHeight = authorFontSize * 1.3;
|
||||
const authorStartY = height - 50 - ((authorLines.length - 1) * authorLineHeight);
|
||||
|
||||
const authorElements = authorLines.map((line, index) => {
|
||||
const y = authorStartY + (index * authorLineHeight);
|
||||
return `<text x="125" y="${y}" text-anchor="middle" font-family="Helvetica, Arial, sans-serif" font-size="${authorFontSize}" fill="${palette.textSecondary}">${this.escapeXml(line)}</text>`;
|
||||
}).join('\n');
|
||||
|
||||
const decorY = titleStartY + (titleLines.length * titleLineHeight) + 20;
|
||||
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
||||
<defs>
|
||||
<linearGradient id="bgGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" style="stop-color:${palette.bg1}"/>
|
||||
<stop offset="100%" style="stop-color:${palette.bg2}"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="spineGrad" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop offset="0%" style="stop-color:rgba(0,0,0,0.4)"/>
|
||||
<stop offset="100%" style="stop-color:rgba(0,0,0,0)"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="url(#bgGrad)"/>
|
||||
<rect x="0" y="0" width="12" height="100%" fill="url(#spineGrad)"/>
|
||||
<rect x="20" y="20" width="${width - 40}" height="${height - 40}" fill="none" stroke="${palette.accent}" stroke-width="1" opacity="0.4" rx="2"/>
|
||||
<rect x="25" y="25" width="${width - 50}" height="${height - 50}" fill="none" stroke="${palette.accent}" stroke-width="0.5" opacity="0.2" rx="1"/>
|
||||
${titleElements}
|
||||
<line x1="80" y1="${decorY}" x2="170" y2="${decorY}" stroke="${palette.accent}" stroke-width="2" stroke-linecap="round"/>
|
||||
<circle cx="125" cy="${decorY}" r="3" fill="${palette.accent}"/>
|
||||
${authorElements}
|
||||
<rect x="0" y="0" width="100%" height="100%" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/>
|
||||
</svg>`;
|
||||
|
||||
return this.svgToDataUrl(svg);
|
||||
}
|
||||
|
||||
private generateAudiobookCover(width: number, height: number, hash: number): string {
|
||||
const palettes = [
|
||||
{bg1: '#667eea', bg2: '#764ba2', accent: '#ffffff', text: '#ffffff', textSecondary: '#e8e8e8'},
|
||||
{bg1: '#f093fb', bg2: '#f5576c', accent: '#ffffff', text: '#ffffff', textSecondary: '#ffeaea'},
|
||||
{bg1: '#4facfe', bg2: '#00f2fe', accent: '#ffffff', text: '#1a1a2e', textSecondary: '#2d3436'},
|
||||
{bg1: '#43e97b', bg2: '#38f9d7', accent: '#ffffff', text: '#1a1a2e', textSecondary: '#2d3436'},
|
||||
{bg1: '#fa709a', bg2: '#fee140', accent: '#ffffff', text: '#1a1a2e', textSecondary: '#2d3436'},
|
||||
{bg1: '#a18cd1', bg2: '#fbc2eb', accent: '#ffffff', text: '#2d3436', textSecondary: '#4a4a4a'},
|
||||
];
|
||||
|
||||
const palette = palettes[hash % palettes.length];
|
||||
const {titleLines, authorLines, titleFontSize, authorFontSize} = this.processText(true);
|
||||
|
||||
const titleLineHeight = titleFontSize * 1.3;
|
||||
const titleStartY = 70;
|
||||
|
||||
const titleElements = titleLines.map((line, index) => {
|
||||
const y = titleStartY + (index * titleLineHeight);
|
||||
return `<text x="125" y="${y}" text-anchor="middle" font-family="Helvetica, Arial, sans-serif" font-weight="700" font-size="${titleFontSize}" fill="${palette.text}">${this.escapeXml(line)}</text>`;
|
||||
}).join('\n');
|
||||
|
||||
const authorLineHeight = authorFontSize * 1.3;
|
||||
const authorStartY = height - 40 - ((authorLines.length - 1) * authorLineHeight);
|
||||
|
||||
const authorElements = authorLines.map((line, index) => {
|
||||
const y = authorStartY + (index * authorLineHeight);
|
||||
return `<text x="125" y="${y}" text-anchor="middle" font-family="Helvetica, Arial, sans-serif" font-size="${authorFontSize}" fill="${palette.textSecondary}">${this.escapeXml(line)}</text>`;
|
||||
}).join('\n');
|
||||
|
||||
const iconY = titleStartY + (titleLines.length * titleLineHeight) + 25;
|
||||
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
||||
<defs>
|
||||
<linearGradient id="bgGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" style="stop-color:${palette.bg1}"/>
|
||||
<stop offset="100%" style="stop-color:${palette.bg2}"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="url(#bgGrad)"/>
|
||||
<circle cx="125" cy="125" r="100" fill="none" stroke="${palette.accent}" stroke-width="1" opacity="0.15"/>
|
||||
<circle cx="125" cy="125" r="80" fill="none" stroke="${palette.accent}" stroke-width="1" opacity="0.1"/>
|
||||
${titleElements}
|
||||
<g transform="translate(125, ${iconY})" opacity="0.9">
|
||||
<circle cx="0" cy="0" r="18" fill="none" stroke="${palette.accent}" stroke-width="2" opacity="0.6"/>
|
||||
<path d="M-6,-8 L-6,8 L8,0 Z" fill="${palette.accent}" opacity="0.8"/>
|
||||
</g>
|
||||
${authorElements}
|
||||
</svg>`;
|
||||
|
||||
return this.svgToDataUrl(svg);
|
||||
}
|
||||
|
||||
private processText(isSquare: boolean): {
|
||||
titleLines: string[];
|
||||
authorLines: string[];
|
||||
titleFontSize: number;
|
||||
authorFontSize: number;
|
||||
} {
|
||||
const maxTitleLength = 60;
|
||||
const maxAuthorLength = 40;
|
||||
const truncatedTitle = this.truncateText(this.title, maxTitleLength);
|
||||
const truncatedAuthor = this.truncateText(this.author, maxAuthorLength);
|
||||
|
||||
const maxLineLength = 12;
|
||||
const maxTitleLines = 4;
|
||||
const maxAuthorLines = 3;
|
||||
const maxLineLength = 14;
|
||||
const maxTitleLines = isSquare ? 3 : 4;
|
||||
const maxAuthorLines = isSquare ? 2 : 3;
|
||||
|
||||
let titleLines = this.wrapText(truncatedTitle, maxLineLength);
|
||||
let authorLines = this.wrapText(truncatedAuthor, maxLineLength);
|
||||
@@ -77,49 +211,24 @@ export class CoverGeneratorComponent {
|
||||
const titleFontSize = this.calculateTitleFontSize(titleLines.length);
|
||||
const authorFontSize = this.calculateAuthorFontSize(authorLines.length);
|
||||
|
||||
const titleLineHeight = titleFontSize * 1.2;
|
||||
const titlePadding = 15;
|
||||
const titleBoxHeight = titleLines.length * titleLineHeight + (titlePadding * 2);
|
||||
return {titleLines, authorLines, titleFontSize, authorFontSize};
|
||||
}
|
||||
|
||||
const titleElements = titleLines.map((line, index) => {
|
||||
const y = 40 + titlePadding + titleFontSize + (index * titleLineHeight);
|
||||
return `<text x="20" y="${y}" font-family="serif" font-size="${titleFontSize}" fill="#000000">${line}</text>`;
|
||||
}).join('\n');
|
||||
private calculateTitleFontSize(lineCount: number): number {
|
||||
if (lineCount <= 2) return 28;
|
||||
if (lineCount === 3) return 24;
|
||||
return 20;
|
||||
}
|
||||
|
||||
const titleWithBackground = `
|
||||
<rect x="0" y="40" width="100%" height="${titleBoxHeight}" fill="url(#titleGradient)" />
|
||||
${titleElements}
|
||||
`;
|
||||
private calculateAuthorFontSize(lineCount: number): number {
|
||||
if (lineCount <= 2) return 18;
|
||||
return 16;
|
||||
}
|
||||
|
||||
const authorLineHeight = authorFontSize * 1.2;
|
||||
const authorStartY = 330 - (authorLines.length - 1) * authorLineHeight;
|
||||
|
||||
const authorElements = authorLines.map((line, index) => {
|
||||
const y = authorStartY + index * authorLineHeight;
|
||||
return `<text x="230" y="${y}" text-anchor="end" font-family="sans-serif" font-size="${authorFontSize}" fill="#000000">${line}</text>`;
|
||||
}).join('\n');
|
||||
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="350" viewBox="0 0 250 350">
|
||||
<defs>
|
||||
<linearGradient id="titleGradient" >
|
||||
<stop style="stop-color:#dddddd;stop-opacity:1;" offset="0" id="stop1" />
|
||||
<stop style="stop-color:#dfdfdf;stop-opacity:0.6;" offset="1" id="stop2" />
|
||||
</linearGradient>
|
||||
<linearGradient id="pageGradient">
|
||||
<stop style="stop-color:#557766;stop-opacity:1;" offset="0" id="stop8" />
|
||||
<stop style="stop-color:#669988;stop-opacity:1;" offset="1" id="stop9" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="url(#pageGradient)" />
|
||||
${titleWithBackground}
|
||||
${authorElements}
|
||||
</svg>
|
||||
`;
|
||||
|
||||
const base64 = btoa(encodeURIComponent(svg).replace(/%([0-9A-F]{2})/g, (match, p1) => {
|
||||
private svgToDataUrl(svg: string): string {
|
||||
const base64 = btoa(encodeURIComponent(svg).replace(/%([0-9A-F]{2})/g, (_, p1) => {
|
||||
return String.fromCharCode(parseInt(p1, 16));
|
||||
}));
|
||||
|
||||
return `data:image/svg+xml;base64,${base64}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {MetadataProviderSpecificFields} from '../model/app-settings.model';
|
||||
|
||||
export type FieldType = 'string' | 'number' | 'array' | 'textarea';
|
||||
export type FieldType = 'string' | 'number' | 'array' | 'textarea' | 'boolean';
|
||||
|
||||
export interface MetadataFieldConfig {
|
||||
label: string;
|
||||
@@ -43,12 +43,23 @@ export const ALL_METADATA_FIELDS: MetadataFieldConfig[] = [
|
||||
{label: 'LB ID', controlName: 'lubimyczytacId', lockedKey: 'lubimyczytacIdLocked', fetchedKey: 'lubimyczytacId', type: 'string', providerKey: 'lubimyczytacId'},
|
||||
{label: 'LB ★', controlName: 'lubimyczytacRating', lockedKey: 'lubimyczytacRatingLocked', fetchedKey: 'lubimyczytacRating', type: 'number', providerKey: 'lubimyczytacRating'},
|
||||
{label: 'Ranobedb ID', controlName: 'ranobedbId', lockedKey: 'ranobedbIdLocked', fetchedKey: 'ranobedbId', type: 'string', providerKey: 'ranobedbId'},
|
||||
{label: 'Ranobedb ★', controlName: 'ranobedbRating', lockedKey: 'ranobedbRatingLocked', fetchedKey: 'ranobedbRating', type: 'number', providerKey: 'ranobedbRating'}
|
||||
{label: 'Ranobedb ★', controlName: 'ranobedbRating', lockedKey: 'ranobedbRatingLocked', fetchedKey: 'ranobedbRating', type: 'number', providerKey: 'ranobedbRating'},
|
||||
{label: 'Audible ID', controlName: 'audibleId', lockedKey: 'audibleIdLocked', fetchedKey: 'audibleId', type: 'string', providerKey: 'audibleId'},
|
||||
{label: 'Audible ★', controlName: 'audibleRating', lockedKey: 'audibleRatingLocked', fetchedKey: 'audibleRating', type: 'number', providerKey: 'audibleRating'},
|
||||
{label: 'Audible #', controlName: 'audibleReviewCount', lockedKey: 'audibleReviewCountLocked', fetchedKey: 'audibleReviewCount', type: 'number', providerKey: 'audibleReviewCount'}
|
||||
];
|
||||
|
||||
// Audiobook content metadata fields (narrator/abridged) - now stored at top level of BookMetadata
|
||||
export const AUDIOBOOK_METADATA_FIELDS: MetadataFieldConfig[] = [
|
||||
{label: 'Narrator', controlName: 'narrator', lockedKey: 'narratorLocked', fetchedKey: 'narrator', type: 'string'},
|
||||
{label: 'Abridged', controlName: 'abridged', lockedKey: 'abridgedLocked', fetchedKey: 'abridged', type: 'boolean'}
|
||||
];
|
||||
|
||||
export const TOP_FIELD_NAMES = ['title', 'subtitle', 'publisher', 'publishedDate'];
|
||||
export const ARRAY_FIELD_NAMES = ['authors', 'categories', 'moods', 'tags'];
|
||||
export const TEXTAREA_FIELD_NAMES = ['description'];
|
||||
export const SERIES_FIELD_NAMES = ['seriesName', 'seriesNumber', 'seriesTotal'];
|
||||
export const BOOK_DETAILS_FIELD_NAMES = ['language', 'isbn10', 'isbn13', 'pageCount'];
|
||||
|
||||
export function getTopFields(): MetadataFieldConfig[] {
|
||||
return ALL_METADATA_FIELDS.filter(f => TOP_FIELD_NAMES.includes(f.controlName));
|
||||
@@ -62,6 +73,26 @@ export function getTextareaFields(): MetadataFieldConfig[] {
|
||||
return ALL_METADATA_FIELDS.filter(f => f.type === 'textarea');
|
||||
}
|
||||
|
||||
export function getSeriesFields(): MetadataFieldConfig[] {
|
||||
return ALL_METADATA_FIELDS.filter(f => SERIES_FIELD_NAMES.includes(f.controlName));
|
||||
}
|
||||
|
||||
export function getBookDetailsFields(): MetadataFieldConfig[] {
|
||||
return ALL_METADATA_FIELDS.filter(f => BOOK_DETAILS_FIELD_NAMES.includes(f.controlName));
|
||||
}
|
||||
|
||||
export function getProviderFields(enabledProviderFields?: MetadataProviderSpecificFields | null): MetadataFieldConfig[] {
|
||||
const providerFields = ALL_METADATA_FIELDS.filter(f => !!f.providerKey);
|
||||
|
||||
if (enabledProviderFields) {
|
||||
return providerFields.filter(field =>
|
||||
!field.providerKey || enabledProviderFields[field.providerKey]
|
||||
);
|
||||
}
|
||||
|
||||
return providerFields;
|
||||
}
|
||||
|
||||
export function getBottomFields(enabledProviderFields?: MetadataProviderSpecificFields | null): MetadataFieldConfig[] {
|
||||
const bottomFields = ALL_METADATA_FIELDS.filter(f =>
|
||||
!TOP_FIELD_NAMES.includes(f.controlName) &&
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {FormControl, FormGroup} from '@angular/forms';
|
||||
import {ALL_METADATA_FIELDS, MetadataFieldConfig} from './metadata-field.config';
|
||||
import {ALL_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELDS, MetadataFieldConfig} from './metadata-field.config';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -22,9 +22,20 @@ export class MetadataFormBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Add audiobook-specific metadata fields
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
const defaultValue = this.getDefaultValue(field.type);
|
||||
controls[field.controlName] = new FormControl(defaultValue);
|
||||
if (includeLockedControls) {
|
||||
controls[field.lockedKey] = new FormControl(false);
|
||||
}
|
||||
}
|
||||
|
||||
controls['thumbnailUrl'] = new FormControl('');
|
||||
controls['audiobookThumbnailUrl'] = new FormControl('');
|
||||
if (includeLockedControls) {
|
||||
controls['coverLocked'] = new FormControl(false);
|
||||
controls['audiobookCoverLocked'] = new FormControl(false);
|
||||
}
|
||||
|
||||
return new FormGroup(controls);
|
||||
@@ -36,6 +47,8 @@ export class MetadataFormBuilder {
|
||||
return [];
|
||||
case 'number':
|
||||
return null;
|
||||
case 'boolean':
|
||||
return null;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
@@ -52,11 +65,19 @@ export class MetadataFormBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Apply locks for standard fields
|
||||
for (const field of fields) {
|
||||
if (lockedFields[field.lockedKey]) {
|
||||
metadataForm.get(field.controlName)?.disable({emitEvent: false});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply locks for audiobook metadata fields
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
if (lockedFields[field.lockedKey]) {
|
||||
metadataForm.get(field.controlName)?.disable({emitEvent: false});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setAllFieldsLocked(metadataForm: FormGroup, locked: boolean): void {
|
||||
|
||||
@@ -117,6 +117,7 @@ export class MetadataUtilsService {
|
||||
copiedFields: Record<string, boolean>,
|
||||
hoveredFields?: Record<string, boolean>
|
||||
): void {
|
||||
// All fields including narrator/abridged are now at top level of BookMetadata
|
||||
metadataForm.get(field)?.setValue(originalMetadata?.[field as keyof BookMetadata]);
|
||||
copiedFields[field] = false;
|
||||
if (hoveredFields) {
|
||||
|
||||
@@ -54,6 +54,7 @@ export interface MetadataProviderSettings {
|
||||
comicvine: Comicvine;
|
||||
douban: Douban;
|
||||
lubimyczytac: Lubimyczytac;
|
||||
audible: Audible;
|
||||
}
|
||||
|
||||
export interface Amazon {
|
||||
@@ -93,6 +94,11 @@ export interface Lubimyczytac {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface Audible {
|
||||
enabled: boolean;
|
||||
domain: string;
|
||||
}
|
||||
|
||||
export interface FormatWriteSettings {
|
||||
enabled: boolean;
|
||||
maxFileSizeInMb: number;
|
||||
@@ -102,6 +108,7 @@ export interface SaveToOriginalFileSettings {
|
||||
epub: FormatWriteSettings;
|
||||
pdf: FormatWriteSettings;
|
||||
cbx: FormatWriteSettings;
|
||||
audiobook: FormatWriteSettings;
|
||||
}
|
||||
|
||||
export interface MetadataPersistenceSettings {
|
||||
@@ -181,6 +188,9 @@ export interface MetadataProviderSpecificFields {
|
||||
lubimyczytacRating: boolean;
|
||||
ranobedbId: boolean;
|
||||
ranobedbRating: boolean;
|
||||
audibleId: boolean;
|
||||
audibleRating: boolean;
|
||||
audibleReviewCount: boolean;
|
||||
}
|
||||
|
||||
export enum AppSettingKey {
|
||||
|
||||
@@ -72,6 +72,42 @@ export class UrlHelperService {
|
||||
return this.appendToken(url);
|
||||
}
|
||||
|
||||
getAudiobookCoverUrl(bookId: number, audiobookCoverUpdatedOn?: string): string {
|
||||
if (!audiobookCoverUpdatedOn) {
|
||||
const book = this.bookService.getBookByIdFromState(bookId);
|
||||
if (book && book.metadata) {
|
||||
const coverGenerator = new CoverGeneratorComponent();
|
||||
coverGenerator.title = book.metadata.title || '';
|
||||
coverGenerator.author = (book.metadata.authors || []).join(', ');
|
||||
coverGenerator.isSquare = true;
|
||||
return coverGenerator.generateCover();
|
||||
}
|
||||
}
|
||||
let url = `${this.mediaBaseUrl}/book/${bookId}/audiobook-cover`;
|
||||
if (audiobookCoverUpdatedOn) {
|
||||
url += `?${audiobookCoverUpdatedOn}`;
|
||||
}
|
||||
return this.appendToken(url);
|
||||
}
|
||||
|
||||
getAudiobookThumbnailUrl(bookId: number, audiobookCoverUpdatedOn?: string): string {
|
||||
if (!audiobookCoverUpdatedOn) {
|
||||
const book = this.bookService.getBookByIdFromState(bookId);
|
||||
if (book && book.metadata) {
|
||||
const coverGenerator = new CoverGeneratorComponent();
|
||||
coverGenerator.title = book.metadata.title || '';
|
||||
coverGenerator.author = (book.metadata.authors || []).join(', ');
|
||||
coverGenerator.isSquare = true;
|
||||
return coverGenerator.generateCover();
|
||||
}
|
||||
}
|
||||
let url = `${this.mediaBaseUrl}/book/${bookId}/audiobook-thumbnail`;
|
||||
if (audiobookCoverUpdatedOn) {
|
||||
url += `?${audiobookCoverUpdatedOn}`;
|
||||
}
|
||||
return this.appendToken(url);
|
||||
}
|
||||
|
||||
getBookdropCoverUrl(bookdropId: number): string {
|
||||
const url = `${this.mediaBaseUrl}/bookdrop/${bookdropId}/cover`;
|
||||
return this.appendToken(url);
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface CoverImage {
|
||||
export interface CoverFetchRequest {
|
||||
title?: string;
|
||||
author?: string;
|
||||
squareCover?: boolean;
|
||||
coverType?: 'ebook' | 'audiobook';
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
|
||||
Reference in New Issue
Block a user