feat(metadata): initial implementation of OpenLibrary source (#1764)

This commit is contained in:
James Ward
2026-09-14 08:49:38 +01:00
committed by GitHub
parent 7a9cd31074
commit 9b38a091e1
72 changed files with 1037 additions and 20 deletions
@@ -23,6 +23,7 @@ export const LOCK_FIELDS = [
'seriesTotalLocked',
'isbn13Locked',
'isbn10Locked',
'openlibraryIdLocked',
'asinLocked',
'comicvineIdLocked',
'goodreadsIdLocked',
@@ -34,7 +34,7 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
bookIds: Set<number> = this.dynamicDialogConfig.data.bookIds;
lockableFields: string[] = [
'titleLocked', 'subtitleLocked', 'publisherLocked', 'publishedDateLocked', 'descriptionLocked',
'titleLocked', 'subtitleLocked', 'publisherLocked', 'publishedDateLocked', 'descriptionLocked', 'openlibraryIdLocked',
'isbn13Locked', 'isbn10Locked', 'asinLocked', 'pageCountLocked', 'thumbnailLocked', 'languageLocked', 'coverLocked',
'seriesNameLocked', 'seriesNumberLocked', 'seriesTotalLocked', 'authorsLocked', 'categoriesLocked', 'moodsLocked', 'tagsLocked',
'amazonRatingLocked', 'amazonReviewCountLocked', 'goodreadsRatingLocked', 'goodreadsReviewCountLocked',
@@ -51,6 +51,7 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
descriptionLocked: 'Description',
isbn13Locked: 'ISBN-13',
isbn10Locked: 'ISBN-10',
openlibraryIdLocked: 'OpenLibrary ID',
asinLocked: 'ASIN',
pageCountLocked: 'Page Count',
thumbnailLocked: 'Thumbnail',
@@ -255,6 +255,7 @@ export interface BookDetailMetadata extends BookMetadataFields {
lubimyczytacId?: string;
ranobedbId?: string;
audibleId?: string;
openlibraryId?: string;
doubanRating?: number;
doubanReviewCount?: number;
lubimyczytacRating?: number;
@@ -300,6 +301,7 @@ export interface BookDetailMetadata extends BookMetadataFields {
lubimyczytacRatingLocked?: boolean;
ranobedbIdLocked?: boolean;
ranobedbRatingLocked?: boolean;
openlibraryIdLocked?: boolean;
audibleIdLocked?: boolean;
audibleRatingLocked?: boolean;
audibleReviewCountLocked?: boolean;
@@ -167,6 +167,7 @@ export interface BookMetadata {
seriesTotal?: number | null;
isbn13?: string;
isbn10?: string;
openlibraryId?: string;
asin?: string;
goodreadsId?: string;
comicvineId?: string;
@@ -220,6 +221,7 @@ export interface BookMetadata {
seriesTotalLocked?: boolean;
isbn13Locked?: boolean;
isbn10Locked?: boolean;
openlibraryIdLocked?: boolean;
asinLocked?: boolean;
comicvineIdLocked?: boolean;
goodreadsIdLocked?: boolean;
@@ -272,6 +274,7 @@ export interface MetadataClearFlags {
seriesTotal?: boolean;
isbn13?: boolean;
isbn10?: boolean;
openlibraryId?: boolean;
asin?: boolean;
goodreadsId?: boolean;
comicvineId?: boolean;
@@ -410,6 +410,7 @@ export class MagicShelfComponent implements OnInit {
{label: this.t.translate('magicShelf.metadataFields.applebooksReviewCount'), value: 'applebooksReviewCount'},
]},
{ label: this.t.translate('magicShelf.metadataFieldGroups.externalIds'), items: [
{label: this.t.translate('magicShelf.metadataFields.openlibraryId'), value: 'openlibraryId'},
{label: this.t.translate('magicShelf.metadataFields.goodreadsId'), value: 'goodreadsId'},
{label: this.t.translate('magicShelf.metadataFields.hardcoverId'), value: 'hardcoverId'},
{label: this.t.translate('magicShelf.metadataFields.googleId'), value: 'googleId'},
@@ -528,6 +528,7 @@ export class BookRuleEvaluatorService {
case 'seriesName': return book.metadata?.seriesName;
case 'isbn13': return book.metadata?.isbn13;
case 'isbn10': return book.metadata?.isbn10;
case 'openlibraryId': return book.metadata?.openlibraryId;
case 'asin': return book.metadata?.asin;
case 'authors': return book.metadata?.authors;
case 'categories': return book.metadata?.categories;
@@ -664,6 +664,20 @@
@if (providerSectionExpanded) {
<div class="collapsible-content">
<div class="field-row metadata-ids-row">
@if (isFieldVisible('openlibraryId')) {
<div class="field-group metadata-id-field">
<label for="openlibraryId">{{ t('openlibraryId') }} @if (isEmbeddable('openlibraryId', book)) { <i class="pi pi-file-export embeddable-indicator" [pTooltip]="t('writtenToFileTooltip')" tooltipPosition="top"></i> }</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="openlibraryId" formControlName="openlibraryId"/>
@if (!book.metadata!['openlibraryIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('openlibraryId')" severity="success"></p-button>
}
@if (book.metadata!['openlibraryIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('openlibraryId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('asin')) {
<div class="field-group metadata-id-field">
<label for="asin">{{ t('amazonAsin') }} @if (isEmbeddable('asin', book)) { <i class="pi pi-file-export embeddable-indicator" [pTooltip]="t('writtenToFileTooltip')" tooltipPosition="top"></i> }</label>
@@ -148,6 +148,7 @@ export class MetadataEditorComponent implements OnInit {
audiobookMetadataFields = AUDIOBOOK_METADATA_FIELDS;
providerSpecificFields: MetadataProviderSpecificFields = {
openlibraryId: true,
asin: true,
amazonRating: true,
amazonReviewCount: true,
@@ -278,6 +279,7 @@ export class MetadataEditorComponent implements OnInit {
description: new FormControl(""),
pageCount: new FormControl(""),
language: new FormControl(""),
openlibraryId: new FormControl(""),
asin: new FormControl(""),
amazonRating: new FormControl(""),
amazonReviewCount: new FormControl(""),
@@ -319,6 +321,7 @@ export class MetadataEditorComponent implements OnInit {
descriptionLocked: new FormControl(false),
pageCountLocked: new FormControl(false),
languageLocked: new FormControl(false),
openlibraryIdLocked: new FormControl(false),
asinLocked: new FormControl(false),
amazonRatingLocked: new FormControl(false),
amazonReviewCountLocked: new FormControl(false),
@@ -424,6 +427,7 @@ export class MetadataEditorComponent implements OnInit {
language: metadata.language ?? null,
rating: metadata.rating ?? null,
reviewCount: metadata.reviewCount ?? null,
openlibraryId: metadata.openlibraryId ?? null,
asin: metadata.asin ?? null,
amazonRating: metadata.amazonRating ?? null,
amazonReviewCount: metadata.amazonReviewCount ?? null,
@@ -462,6 +466,7 @@ export class MetadataEditorComponent implements OnInit {
descriptionLocked: metadata.descriptionLocked ?? false,
pageCountLocked: metadata.pageCountLocked ?? false,
languageLocked: metadata.languageLocked ?? false,
openlibraryIdLocked: metadata.openlibraryIdLocked ?? false,
asinLocked: metadata.asinLocked ?? false,
amazonRatingLocked: metadata.amazonRatingLocked ?? false,
amazonReviewCountLocked: metadata.amazonReviewCountLocked ?? false,
@@ -535,6 +540,7 @@ export class MetadataEditorComponent implements OnInit {
{key: "languageLocked", control: "language"},
{key: "isbn10Locked", control: "isbn10"},
{key: "isbn13Locked", control: "isbn13"},
{key: "openlibraryIdLocked", control: "openlibraryId"},
{key: "asinLocked", control: "asin"},
{key: "amazonReviewCountLocked", control: "amazonReviewCount"},
{key: "amazonRatingLocked", control: "amazonRating"},
@@ -729,6 +735,7 @@ export class MetadataEditorComponent implements OnInit {
pageCount: form.get("pageCount")?.value,
rating: form.get("rating")?.value,
reviewCount: form.get("reviewCount")?.value,
openlibraryId: form.get("openlibraryId")?.value,
asin: form.get("asin")?.value,
amazonRating: form.get("amazonRating")?.value,
amazonReviewCount: form.get("amazonReviewCount")?.value,
@@ -778,6 +785,7 @@ export class MetadataEditorComponent implements OnInit {
descriptionLocked: form.get("descriptionLocked")?.value,
pageCountLocked: form.get("pageCountLocked")?.value,
languageLocked: form.get("languageLocked")?.value,
openlibraryIdLocked: form.get("openlibraryIdLocked")?.value,
asinLocked: form.get("asinLocked")?.value,
amazonRatingLocked: form.get("amazonRatingLocked")?.value,
amazonReviewCountLocked: form.get("amazonReviewCountLocked")?.value,
@@ -871,6 +879,7 @@ export class MetadataEditorComponent implements OnInit {
description: wasCleared("description"),
pageCount: wasCleared("pageCount"),
language: wasCleared("language"),
openlibraryId: wasCleared("openlibraryId"),
asin: wasCleared("asin"),
amazonRating: wasCleared("amazonRating"),
amazonReviewCount: wasCleared("amazonReviewCount"),
@@ -327,6 +327,7 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
private getProviderFromMetadata(metadata: BookMetadata): string | null {
if (metadata.audibleId) return 'audible';
if (metadata.applebooksId) return 'applebooks';
if (metadata.openlibraryId) return 'openlibrary';
if (metadata.asin) return 'amazon';
if (metadata.goodreadsId) return 'goodreads';
if (metadata.googleId) return 'google';
@@ -443,6 +444,7 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
case 'GoodReads': return metadata.goodreadsId;
case 'Amazon': return metadata.asin;
case 'Audible': return metadata.audibleId;
case 'OpenLibrary': return metadata.openlibraryId;
default: return undefined;
}
}
@@ -467,6 +469,10 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
return metadata.externalUrl;
}
if (metadata.openlibraryId) {
return `https://openlibrary.org/${metadata.openlibraryId.replace(/^\//, '')}`
}
if (metadata.audibleId) {
// Audible has to come before Amazon because they both have an ASIN.
return `https://www.audible.com/pd/${metadata.audibleId}`;
@@ -526,6 +532,10 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
return metadata.provider;
}
if (metadata.openlibraryId) {
return 'OpenLibrary';
}
if (metadata.audibleId) {
// Audible has to come before Amazon because they both have an ASIN.
return 'Audible';
@@ -571,7 +581,7 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
}
trackByMetadata(index: number, metadata: BookMetadata): string {
return metadata.googleId || metadata.goodreadsId || metadata.asin ||
return metadata.openlibraryId || metadata.googleId || metadata.goodreadsId || metadata.asin ||
metadata.hardcoverId || metadata.comicvineId || metadata.audibleId ||
metadata.applebooksId || index.toString();
}
@@ -30,6 +30,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
'title', 'subtitle', 'description', 'authors', 'publisher', 'publishedDate',
'seriesName', 'seriesNumber', 'seriesTotal', 'isbn13', 'isbn10',
'language', 'categories', 'cover', 'pageCount',
'openlibraryId',
'asin', 'amazonRating', 'amazonReviewCount',
'googleId',
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
@@ -42,6 +43,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
];
providerSpecificFields: (keyof FieldOptions)[] = [
'openlibraryId',
'asin', 'amazonRating', 'amazonReviewCount',
'googleId',
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
@@ -59,8 +61,33 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
'language', 'categories', 'cover', 'pageCount',
];
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb', 'Audible', 'AppleBooks'];
providersWithClear: string[] = ['Clear All', 'Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb', 'Audible', 'AppleBooks'];
providers: string[] = [
'OpenLibrary',
'Amazon',
'Google',
'GoodReads',
'Hardcover',
'Comicvine',
'Douban',
'Lubimyczytac',
'Ranobedb',
'Audible',
'AppleBooks'
];
providersWithClear: string[] = [
'Clear All',
'OpenLibrary',
'Amazon',
'Google',
'GoodReads',
'Hardcover',
'Comicvine',
'Douban',
'Lubimyczytac',
'Ranobedb',
'Audible',
'AppleBooks'
];
refreshCovers: boolean = false;
mergeCategories: boolean = false;
@@ -89,6 +116,9 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
private justSubmitted = false;
private providerSpecificFieldsList = [
// OpenLibrary
'openlibraryId',
// Amazon
'asin', 'amazonRating', 'amazonReviewCount',
@@ -273,6 +303,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
'pageCount': 'Page Count',
'rating': 'Rating',
'reviewCount': 'Review Count',
'openlibraryId': 'OpenLibrary ID',
'asin': 'Amazon ASIN',
'goodreadsId': 'Goodreads ID',
'comicvineId': 'Comicvine ID',
@@ -19,6 +19,7 @@ export class MetadataProviderFieldSelectorComponent {
private t = inject(TranslocoService);
providerGroups: { labelKey: string, fields: string[] }[] = [
{labelKey: 'openlibrary', fields: ['openlibraryId']},
{labelKey: 'amazon', fields: ['asin', 'amazonRating', 'amazonReviewCount']},
{labelKey: 'googleBooks', fields: ['googleId']},
{labelKey: 'goodreads', fields: ['goodreadsId', 'goodreadsRating', 'goodreadsReviewCount']},
@@ -39,6 +40,7 @@ export class MetadataProviderFieldSelectorComponent {
}
private readonly allFieldNames: (keyof MetadataProviderSpecificFields)[] = [
'openlibraryId',
'asin', 'amazonRating', 'amazonReviewCount',
'googleId',
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
@@ -17,6 +17,7 @@ const provider = (value: string | null): FieldProvider => ({
describe('metadata-refresh-options.model', () => {
it('supports replace-mode driven refresh settings', () => {
const fieldOptions: FieldOptions = {
openlibraryId: provider('openlibrary'),
title: provider('google'),
description: provider('google'),
authors: provider('google'),
@@ -81,6 +82,7 @@ describe('metadata-refresh-options.model', () => {
isbn10: true,
language: true,
pageCount: true,
openlibraryId: true,
asin: true,
goodreadsId: true,
comicvineId: false,
@@ -38,6 +38,7 @@ export interface FieldOptions {
isbn10: FieldProvider;
language: FieldProvider;
pageCount: FieldProvider;
openlibraryId: FieldProvider;
asin: FieldProvider;
goodreadsId: FieldProvider;
comicvineId: FieldProvider;
@@ -24,6 +24,7 @@ export interface SidecarIdentifiers {
ranobedbId?: string;
audibleId?: string;
applebooksId?: string;
openlibraryId?: string;
}
export interface SidecarRating {
@@ -194,6 +194,13 @@
<h4 class="provider-group-title">{{ t('readyToUseTitle') }}</h4>
<div class="simple-providers-grid">
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="openLibraryEnabled"></p-toggleswitch>
<span class="setting-label">OpenLibrary</span>
</div>
</div>
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="goodreadsEnabled"></p-toggleswitch>
@@ -103,6 +103,7 @@ export class MetadataProviderSettingsComponent {
amazonCookie: string = '';
hardcoverEnabled: boolean = false;
amazonEnabled: boolean = false;
openLibraryEnabled: boolean = false;
goodreadsEnabled: boolean = false;
googleEnabled: boolean = false;
comicvineEnabled: boolean = false;
@@ -128,6 +129,7 @@ export class MetadataProviderSettingsComponent {
private applySettings(settings: NonNullable<ReturnType<typeof this.appSettingsService.appSettings>>): void {
const metadataProviderSettings = settings.metadataProviderSettings;
this.openLibraryEnabled = metadataProviderSettings?.openLibrary?.enabled ?? false;
this.amazonEnabled = metadataProviderSettings?.amazon?.enabled ?? false;
this.amazonCookie = metadataProviderSettings?.amazon?.cookie ?? "";
this.selectedAmazonDomain = metadataProviderSettings?.amazon?.domain ?? 'com';
@@ -169,6 +171,9 @@ export class MetadataProviderSettingsComponent {
{
key: AppSettingKey.METADATA_PROVIDER_SETTINGS,
newValue: {
openLibrary: {
enabled: this.openLibraryEnabled,
},
amazon: {
enabled: this.amazonEnabled,
cookie: this.amazonCookie,
@@ -221,6 +221,7 @@ export class LibraryMetadataSettingsComponent {
categories: {p1: null, p2: null, p3: null, p4: null},
cover: {p1: null, p2: null, p3: null, p4: null},
pageCount: {p1: null, p2: null, p3: null, p4: null},
openlibraryId: {p1: null, p2: null, p3: null, p4: null},
asin: {p1: null, p2: null, p3: null, p4: null},
goodreadsId: {p1: null, p2: null, p3: null, p4: null},
comicvineId: {p1: null, p2: null, p3: null, p4: null},
@@ -94,7 +94,7 @@ function buildMetadataRefreshOptions(): MetadataRefreshOptions {
const FIELDS = [
'title', 'subtitle', 'description', 'authors', 'publisher', 'publishedDate',
'seriesName', 'seriesNumber', 'seriesTotal', 'isbn13', 'isbn10', 'language',
'pageCount', 'categories', 'cover', 'asin', 'goodreadsId', 'comicvineId',
'pageCount', 'categories', 'cover', 'asin', 'goodreadsId', 'comicvineId', 'openlibraryId',
'hardcoverId', 'hardcoverBookId', 'googleId', 'lubimyczytacId',
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating',
@@ -5,7 +5,7 @@ const EBOOK_EMBEDDABLE: ReadonlySet<string> = new Set([
'title', 'subtitle', 'authors', 'publisher', 'publishedDate', 'language',
'categories', 'description', 'seriesName', 'seriesNumber', 'seriesTotal',
'isbn10', 'isbn13', 'moods', 'tags', 'ageRating', 'contentRating', 'pageCount',
'asin', 'amazonRating', 'amazonReviewCount', 'googleId',
'openlibraryId', 'asin', 'amazonRating', 'amazonReviewCount', 'googleId',
'applebooksId', 'applebooksRating', 'applebooksReviewCount',
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
'hardcoverId', 'hardcoverBookId', 'hardcoverRating', 'hardcoverReviewCount',
@@ -41,6 +41,7 @@ describe('metadata-field.config', () => {
it('filters provider-backed fields when provider flags are supplied', () => {
const enabledFields = {
openlibraryId: false,
googleId: true,
asin: false,
amazonRating: false,
@@ -28,6 +28,7 @@ export const ALL_METADATA_FIELDS: MetadataFieldConfig[] = [
{ label: 'ISBN-10', controlName: 'isbn10', lockedKey: 'isbn10Locked', fetchedKey: 'isbn10', type: 'string' },
{ label: 'ISBN-13', controlName: 'isbn13', lockedKey: 'isbn13Locked', fetchedKey: 'isbn13', type: 'string' },
{ label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount', type: 'number' },
{ label: 'OpenLibrary ID', controlName: 'openlibraryId', lockedKey: 'openlibraryIdLocked', fetchedKey: 'openlibraryId', type: 'string', providerKey: 'openlibraryId' },
{ label: 'Google ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleId', type: 'string', providerKey: 'googleId' },
{ label: 'ASIN', controlName: 'asin', lockedKey: 'asinLocked', fetchedKey: 'asin', type: 'string', providerKey: 'asin' },
{ label: 'Amazon #', controlName: 'amazonReviewCount', lockedKey: 'amazonReviewCountLocked', fetchedKey: 'amazonReviewCount', type: 'number', providerKey: 'amazonReviewCount' },
@@ -51,6 +51,7 @@ export interface OidcAutoProvisionDetails {
}
export interface MetadataProviderSettings {
openLibrary: OpenLibrary;
amazon: Amazon;
google: Google;
goodReads: Goodreads;
@@ -63,6 +64,10 @@ export interface MetadataProviderSettings {
appleBooks: AppleBooks;
}
export interface OpenLibrary {
enabled: boolean;
}
export interface Amazon {
enabled: boolean;
cookie: string;
@@ -209,6 +214,7 @@ export interface AppSettings {
}
export interface MetadataProviderSpecificFields {
openlibraryId: boolean;
asin: boolean;
amazonRating: boolean;
amazonReviewCount: boolean;
+4
View File
@@ -768,6 +768,7 @@
"sectionTitle": "Enabled Fields in Metadata Editor & Picker",
"sectionDesc": "Select which metadata fields to display when editing book information or picking metadata from providers. Disabled fields will be hidden from the interface.",
"providers": {
"openlibrary": "OpenLibrary",
"amazon": "Amazon",
"googleBooks": "Google Books",
"goodreads": "Goodreads",
@@ -779,6 +780,7 @@
"ranobedb": "Ranobedb"
},
"fields": {
"openlibraryId": "OpenLibrary ID",
"asin": "Amazon ASIN",
"amazonRating": "Amazon Rating",
"amazonReviewCount": "Amazon Review Count",
@@ -2253,6 +2255,7 @@
"audiobookDetails": "Audiobook Details",
"comicBookDetails": "Comic Book Details",
"providerMetadata": "Provider Metadata",
"openlibraryId": "OpenLibrary ID",
"amazonAsin": "Amazon ASIN",
"amazonRating": "Amazon ★",
"amazonReviewCount": "Amazon #",
@@ -5222,6 +5225,7 @@
"hardcoverReviewCount": "Hardcover Reviews",
"audibleReviewCount": "Audible Reviews",
"applebooksReviewCount": "Apple Books Review Count",
"openlibraryId": "OpenLibrary ID",
"goodreadsId": "Goodreads ID",
"hardcoverId": "Hardcover ID",
"googleId": "Google ID",