2022-04-14 17:15:52 -05:00
|
|
|
const { BookCoverAspectRatio } = require('../../utils/constants')
|
|
|
|
|
|
|
|
class LibrarySettings {
|
|
|
|
constructor(settings) {
|
2022-08-13 13:56:37 -05:00
|
|
|
this.coverAspectRatio = BookCoverAspectRatio.SQUARE
|
2022-04-14 17:15:52 -05:00
|
|
|
this.disableWatcher = false
|
2022-04-26 17:36:29 -07:00
|
|
|
this.skipMatchingMediaWithAsin = false
|
|
|
|
this.skipMatchingMediaWithIsbn = false
|
2022-08-16 18:24:47 -05:00
|
|
|
this.autoScanCronExpression = null
|
2023-06-10 12:46:57 -05:00
|
|
|
this.audiobooksOnly = false
|
2022-04-14 17:15:52 -05:00
|
|
|
|
|
|
|
if (settings) {
|
|
|
|
this.construct(settings)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
construct(settings) {
|
2022-08-13 13:56:37 -05:00
|
|
|
this.coverAspectRatio = !isNaN(settings.coverAspectRatio) ? settings.coverAspectRatio : BookCoverAspectRatio.SQUARE
|
2022-04-14 17:15:52 -05:00
|
|
|
this.disableWatcher = !!settings.disableWatcher
|
2022-04-26 17:36:29 -07:00
|
|
|
this.skipMatchingMediaWithAsin = !!settings.skipMatchingMediaWithAsin
|
|
|
|
this.skipMatchingMediaWithIsbn = !!settings.skipMatchingMediaWithIsbn
|
2022-08-16 18:24:47 -05:00
|
|
|
this.autoScanCronExpression = settings.autoScanCronExpression || null
|
2023-06-10 12:46:57 -05:00
|
|
|
this.audiobooksOnly = !!settings.audiobooksOnly
|
2022-04-14 17:15:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
toJSON() {
|
|
|
|
return {
|
2022-08-13 13:56:37 -05:00
|
|
|
coverAspectRatio: this.coverAspectRatio,
|
2022-04-26 17:36:29 -07:00
|
|
|
disableWatcher: this.disableWatcher,
|
|
|
|
skipMatchingMediaWithAsin: this.skipMatchingMediaWithAsin,
|
2022-08-16 18:24:47 -05:00
|
|
|
skipMatchingMediaWithIsbn: this.skipMatchingMediaWithIsbn,
|
2023-06-10 12:46:57 -05:00
|
|
|
autoScanCronExpression: this.autoScanCronExpression,
|
|
|
|
audiobooksOnly: this.audiobooksOnly
|
2022-04-14 17:15:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update(payload) {
|
2023-06-10 12:46:57 -05:00
|
|
|
let hasUpdates = false
|
2022-04-14 17:15:52 -05:00
|
|
|
for (const key in payload) {
|
|
|
|
if (this[key] !== payload[key]) {
|
|
|
|
this[key] = payload[key]
|
|
|
|
hasUpdates = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hasUpdates
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = LibrarySettings
|