2021-09-22 03:57:33 +02:00
|
|
|
const { CoverDestination } = require('../utils/constants')
|
|
|
|
|
2021-09-05 02:58:39 +02:00
|
|
|
class ServerSettings {
|
|
|
|
constructor(settings) {
|
|
|
|
this.id = 'server-settings'
|
|
|
|
this.autoTagNew = false
|
|
|
|
this.newTagExpireDays = 15
|
|
|
|
this.scannerParseSubtitle = false
|
2021-09-22 03:57:33 +02:00
|
|
|
this.coverDestination = CoverDestination.METADATA
|
2021-09-05 02:58:39 +02:00
|
|
|
|
|
|
|
if (settings) {
|
|
|
|
this.construct(settings)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
construct(settings) {
|
|
|
|
this.autoTagNew = settings.autoTagNew
|
|
|
|
this.newTagExpireDays = settings.newTagExpireDays
|
|
|
|
this.scannerParseSubtitle = settings.scannerParseSubtitle
|
2021-09-22 03:57:33 +02:00
|
|
|
this.coverDestination = settings.coverDestination || CoverDestination.METADATA
|
2021-09-05 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
toJSON() {
|
|
|
|
return {
|
|
|
|
id: this.id,
|
|
|
|
autoTagNew: this.autoTagNew,
|
|
|
|
newTagExpireDays: this.newTagExpireDays,
|
2021-09-22 03:57:33 +02:00
|
|
|
scannerParseSubtitle: this.scannerParseSubtitle,
|
|
|
|
coverDestination: this.coverDestination
|
2021-09-05 02:58:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update(payload) {
|
|
|
|
var hasUpdates = false
|
|
|
|
for (const key in payload) {
|
|
|
|
if (this[key] !== payload[key]) {
|
|
|
|
this[key] = payload[key]
|
|
|
|
hasUpdates = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hasUpdates
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = ServerSettings
|