From 84dd06dfc4ef9a26c50a435cc150bc920437eb31 Mon Sep 17 00:00:00 2001 From: Selfhost Alt Date: Tue, 26 Apr 2022 17:36:29 -0700 Subject: [PATCH] Add options to skip matching media items if they already have an ASIN/ISBN --- .../components/modals/libraries/EditModal.vue | 4 +++- .../modals/libraries/LibrarySettings.vue | 22 +++++++++++++++++-- server/objects/settings/LibrarySettings.js | 8 ++++++- server/scanner/Scanner.js | 15 +++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/client/components/modals/libraries/EditModal.vue b/client/components/modals/libraries/EditModal.vue index 4e348d7f..0baa3d88 100644 --- a/client/components/modals/libraries/EditModal.vue +++ b/client/components/modals/libraries/EditModal.vue @@ -93,7 +93,9 @@ export default { icon: 'database', mediaType: 'book', settings: { - disableWatcher: false + disableWatcher: false, + skipMatchingMediaWithAsin: false, + skipMatchingMediaWithIsbn: false, } } }, diff --git a/client/components/modals/libraries/LibrarySettings.vue b/client/components/modals/libraries/LibrarySettings.vue index c27f4838..caabc8b9 100644 --- a/client/components/modals/libraries/LibrarySettings.vue +++ b/client/components/modals/libraries/LibrarySettings.vue @@ -8,6 +8,18 @@

*Watcher is disabled globally in server settings

+
+
+ +

Skip matching books that already have an ASIN

+
+
+
+
+ +

Skip matching books that already have an ISBN

+
+
@@ -23,7 +35,9 @@ export default { data() { return { provider: null, - disableWatcher: false + disableWatcher: false, + skipMatchingMediaWithAsin: false, + skipMatchingMediaWithIsbn: false, } }, computed: { @@ -45,7 +59,9 @@ export default { getLibraryData() { return { settings: { - disableWatcher: !!this.disableWatcher + disableWatcher: !!this.disableWatcher, + skipMatchingMediaWithAsin: !!this.skipMatchingMediaWithAsin, + skipMatchingMediaWithIsbn: !!this.skipMatchingMediaWithIsbn } } }, @@ -54,6 +70,8 @@ export default { }, init() { this.disableWatcher = !!this.librarySettings.disableWatcher + this.skipMatchingMediaWithAsin = !!this.librarySettings.skipMatchingMediaWithAsin + this.skipMatchingMediaWithIsbn = !!this.librarySettings.skipMatchingMediaWithIsbn } }, mounted() { diff --git a/server/objects/settings/LibrarySettings.js b/server/objects/settings/LibrarySettings.js index 853962ad..25c82f28 100644 --- a/server/objects/settings/LibrarySettings.js +++ b/server/objects/settings/LibrarySettings.js @@ -4,6 +4,8 @@ const Logger = require('../../Logger') class LibrarySettings { constructor(settings) { this.disableWatcher = false + this.skipMatchingMediaWithAsin = false + this.skipMatchingMediaWithIsbn = false if (settings) { this.construct(settings) @@ -12,11 +14,15 @@ class LibrarySettings { construct(settings) { this.disableWatcher = !!settings.disableWatcher + this.skipMatchingMediaWithAsin = !!settings.skipMatchingMediaWithAsin + this.skipMatchingMediaWithIsbn = !!settings.skipMatchingMediaWithIsbn } toJSON() { return { - disableWatcher: this.disableWatcher + disableWatcher: this.disableWatcher, + skipMatchingMediaWithAsin: this.skipMatchingMediaWithAsin, + skipMatchingMediaWithIsbn: this.skipMatchingMediaWithIsbn } } diff --git a/server/scanner/Scanner.js b/server/scanner/Scanner.js index 19fd3c99..8b3c7564 100644 --- a/server/scanner/Scanner.js +++ b/server/scanner/Scanner.js @@ -726,6 +726,21 @@ class Scanner { for (let i = 0; i < itemsInLibrary.length; i++) { var libraryItem = itemsInLibrary[i] + + if (libraryItem.media.metadata.asin && library.settings.skipMatchingMediaWithAsin) { + Logger.debug(`[Scanner] matchLibraryItems: Skipping "${ + libraryItem.media.metadata.title + }" because it already has an ASIN (${i + 1} of ${itemsInLibrary.length})`) + continue; + } + + if (libraryItem.media.metadata.isbn && library.settings.skipMatchingMediaWithIsbn) { + Logger.debug(`[Scanner] matchLibraryItems: Skipping "${ + libraryItem.media.metadata.title + }" because it already has an ISBN (${i + 1} of ${itemsInLibrary.length})`) + continue; + } + Logger.debug(`[Scanner] matchLibraryItems: Quick matching "${libraryItem.media.metadata.title}" (${i + 1} of ${itemsInLibrary.length})`) var result = await this.quickMatchLibraryItem(libraryItem, { provider }) if (result.warning) {