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
|
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,
|
|
|
|
preferOpfMetadata: this.preferOpfMetadata
|
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
|
2021-11-23 02:58:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = ScanOptions
|