feat(metadata): initial implementation of OpenLibrary source (#1764)
This commit is contained in:
+14
@@ -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>
|
||||
|
||||
+9
@@ -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"),
|
||||
|
||||
+11
-1
@@ -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();
|
||||
}
|
||||
|
||||
+33
-2
@@ -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',
|
||||
|
||||
+2
@@ -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',
|
||||
|
||||
+2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user