2021-11-23 02:58:20 +01:00
|
|
|
class ScanOptions {
|
|
|
|
constructor(options) {
|
|
|
|
this.forceRescan = false
|
|
|
|
|
|
|
|
// Server settings
|
|
|
|
this.parseSubtitles = false
|
|
|
|
this.findCovers = false
|
2022-04-12 23:05:16 +02:00
|
|
|
this.storeCoverWithItem = false
|
2021-11-25 03:15:50 +01:00
|
|
|
this.preferAudioMetadata = false
|
|
|
|
this.preferOpfMetadata = false
|
2022-05-23 04:56:51 +02:00
|
|
|
this.preferMatchedMetadata = false
|
2021-11-23 02:58:20 +01:00
|
|
|
|
|
|
|
if (options) {
|
|
|
|
this.construct(options)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
construct(options) {
|
|
|
|
for (const key in options) {
|
|
|
|
if (key === 'metadataPrecedence' && options[key].length) {
|
|
|
|
this.metadataPrecedence = [...options[key]]
|
|
|
|
} else if (this[key] !== undefined) {
|
|
|
|
this[key] = options[key]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toJSON() {
|
|
|
|
return {
|
|
|
|
forceRescan: this.forceRescan,
|
|
|
|
metadataPrecedence: this.metadataPrecedence,
|
|
|
|
parseSubtitles: this.parseSubtitles,
|
|
|
|
findCovers: this.findCovers,
|
2022-04-12 23:05:16 +02:00
|
|
|
storeCoverWithItem: this.storeCoverWithItem,
|
2021-11-25 03:15:50 +01:00
|
|
|
preferAudioMetadata: this.preferAudioMetadata,
|
2022-05-23 04:56:51 +02:00
|
|
|
preferOpfMetadata: this.preferOpfMetadata,
|
|
|
|
preferOpfMetadata: this.preferMatchedMetadata
|
2021-11-23 02:58:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setData(options, serverSettings) {
|
|
|
|
this.forceRescan = !!options.forceRescan
|
|
|
|
|
|
|
|
this.parseSubtitles = !!serverSettings.scannerParseSubtitle
|
|
|
|
this.findCovers = !!serverSettings.scannerFindCovers
|
2022-04-12 23:05:16 +02:00
|
|
|
this.storeCoverWithItem = serverSettings.storeCoverWithItem
|
2021-11-25 03:15:50 +01:00
|
|
|
this.preferAudioMetadata = serverSettings.scannerPreferAudioMetadata
|
|
|
|
this.preferOpfMetadata = serverSettings.scannerPreferOpfMetadata
|
2022-05-23 04:56:51 +02:00
|
|
|
this.preferOpfMetadata = serverSettings.scannerPreferMatchedMetadata
|
2021-11-23 02:58:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = ScanOptions
|